bool Analysis_Impl::setProblem(Problem& problem) { // problem is in charge of making sure it is internally consistent // need problem to be consistent with seed if (problem.inputFileType() && (seed().fileType() != problem.inputFileType().get())) { LOG(Error,"Cannot set problem to '" << problem.name() << "', because its input file type is " << problem.inputFileType().get().valueName() << " and the seed model type is " << seed().fileType().valueName() << "."); return false; } // need problem to be consistent with algorithm if (m_algorithm && !(m_algorithm->isCompatibleProblemType(problem))) { LOG(Error,"Cannot set problem to '" << problem.name() << "', because it is not compatible " << "with Algorithm '" << m_algorithm->name() << "'."); return false; } disconnectChild(m_problem); m_problem = problem; connectChild(m_problem,true); onChange(AnalysisObject_Impl::InvalidatesDataPoints); return true; }
bool MeasureGroup_Impl::insert(int index, const Measure& measure) { if ((index < 0) || (index > int(numMeasures(false)))) { return false; } if (index == int(numMeasures(false))) { return push(measure); } // position does not matter for compatibility checking MeasureVector candidates = measures(false); candidates.push_back(measure); if (!measuresAreCompatible(candidates)) { return false; } auto it = m_measures.begin(); for (int count = 0; count < index; ++count, ++it); it = m_measures.insert(it,measure); for (int i = index, n = int(m_measures.size()); i < n; ++i) { m_measures[i].onChange(); } connectChild(m_measures[index],true); onChange(AnalysisObject_Impl::InvalidatesDataPoints); return true; }
MeasureGroup_Impl::MeasureGroup_Impl(const MeasureGroup_Impl &other) : DiscreteVariable_Impl(other) { for (const Measure& pert : other.measures(false)) { m_measures.push_back(pert.clone().cast<Measure>()); connectChild(m_measures.back(),false); } }
Function_Impl::Function_Impl(const Function_Impl &other) : AnalysisObject_Impl(other) { for (const Variable& var : other.variables()) { m_variables.push_back(var.clone().cast<Variable>()); connectChild(m_variables.back(),false); } }
Function_Impl::Function_Impl(const std::string& name, const std::vector<Variable>& variables) : AnalysisObject_Impl(name), m_variables(variables) { for (Variable& variable : m_variables) { variable.onChange(); connectChild(variable,false); } }
bool RubyContinuousVariable_Impl::setRubyMeasure(const RubyMeasure& measure) { if (!fileTypesAreCompatible(m_measure, measure.inputFileType(), measure.outputFileType())) { return false; } disconnectChild(m_measure); m_measure = measure; connectChild(m_measure,true); onChange(AnalysisObject_Impl::InvalidatesResults); return true; }
bool MeasureGroup_Impl::push(const Measure& measure) { MeasureVector candidates = measures(false); candidates.push_back(measure); if (!measuresAreCompatible(candidates)) { return false; } m_measures.push_back(measure); m_measures.back().onChange(); connectChild(m_measures.back(),true); onChange(AnalysisObject_Impl::Benign); return true; }
Function_Impl::Function_Impl(const UUID& uuid, const UUID& versionUUID, const std::string& name, const std::string& displayName, const std::string& description, const std::vector<Variable>& variables) : AnalysisObject_Impl(uuid,versionUUID,name,displayName,description), m_variables(variables) { for (Variable& variable : m_variables) { connectChild(variable,false); } }
bool Analysis_Impl::setAlgorithm(Algorithm& algorithm) { if (!algorithm.isCompatibleProblemType(m_problem)) { LOG(Error,"Cannot set algorithm to '" << algorithm.name() << "', because it is incompatible " << "with this analysis's current problem '" << m_problem.name() << "'."); return false; } if (m_algorithm) { disconnectChild(*m_algorithm); } m_algorithm = algorithm; connectChild(*m_algorithm,true); onChange(AnalysisObject_Impl::Benign); return true; }
MeasureGroup_Impl::MeasureGroup_Impl( const UUID& uuid, const UUID& versionUUID, const std::string& name, const std::string& displayName, const std::string& description, const boost::optional<UncertaintyDescription>& udesc, const std::vector<Measure>& measures) : DiscreteVariable_Impl(uuid,versionUUID,name,displayName,description,udesc), m_measures(measures) { for (Measure& measure : m_measures) { connectChild(measure,false); } }
bool MeasureGroup_Impl::setMeasures(const std::vector<Measure>& measures) { if (!measuresAreCompatible(measures)) { return false; } for (Measure& measure : m_measures) { disconnectChild(measure); } m_measures = measures; for (Measure& measure : m_measures) { measure.onChange(); connectChild(measure,true); } onChange(AnalysisObject_Impl::InvalidatesDataPoints); return true; }
MeasureGroup_Impl::MeasureGroup_Impl(const std::string& name, const std::vector<Measure>& measures) : DiscreteVariable_Impl(name), m_measures(measures) { // get null measures straightened out bool hasNull(false); bool isSelected(false); auto it = m_measures.begin(); while (it != m_measures.end()) { if (OptionalNullMeasure oNull = it->optionalCast<NullMeasure>()) { if (isSelected && oNull->isSelected()) { it = m_measures.erase(it); // only let there be one NullMeasure that is selected. continue; } hasNull = true; if (!isSelected) { isSelected = oNull->isSelected(); } } ++it; } // throw if measure file types are inconsistent. std::pair<bool,OptionalFileReferenceType> inType = detail::inputFileType(measures); std::pair<bool,OptionalFileReferenceType> outType = detail::outputFileType(measures); if (!inType.first) { LOG_AND_THROW("Input file types of measures used to attempt to construct " << "MeasureGroup '" << name << "' are inconsistent."); } if (!outType.first) { LOG_AND_THROW("Output file types of measures used to attempt to construct " << "MeasureGroup '" << name << "' are inconsistent."); } if (hasNull && inType.second && outType.second && (inType.second.get() != outType.second.get())) { LOG_AND_THROW("Unable to construct MeasureGroup '" << name << "', because at least one measure changes the file type between input and " << "output, and there is also a NullMeasure (which cannot change the file type)."); } for (Measure& measure : m_measures) { measure.onChange(); connectChild(measure,false); } }
bool Analysis_Impl::addDataPoint(const DataPoint& dataPoint) { if (m_dataPointsAreInvalid) { LOG(Info,"Current data points are invalid. Call removeAllDataPoints before adding new ones."); return false; } if (!(dataPoint.problem().uuid() == problem().uuid())) { LOG(Error,"Cannot add given DataPoint to Analysis '" << name() << "', because it is not associated with Problem '" << problem().name() << "'."); return false; } DataPointVector existingDataPoints = getDataPoints(dataPoint.variableValues()); if (existingDataPoints.size() > 0) { BOOST_ASSERT(existingDataPoints.size() == 1); // dataPoint must be fully specified to be valid LOG(Info,"DataPoint not added to Analysis '" << name() << "', because it already exists."); return false; } m_dataPoints.push_back(dataPoint); connectChild(m_dataPoints.back(),true); onChange(AnalysisObject_Impl::Benign); return true; }
void RTValViewItem::doAppendChildViewItems( QList<BaseViewItem*>& items ) { if (!m_val.isValid()) return; FabricCore::RTVal desc = m_val.getJSON(); const char* cdesc = desc.getStringCString(); // TODO: parse cdesc, Build children from desc. try { FTL::JSONValue* value = FTL::JSONValue::Decode( cdesc ); FTL::JSONObject* obj = value->cast<FTL::JSONObject>(); // Construct a child for each instance ViewItemFactory* factory = ViewItemFactory::GetInstance(); for (FTL::JSONObject::const_iterator itr = obj->begin(); itr != obj->end(); itr++) { const char* childName = itr->first.c_str(); FabricCore::RTVal childVal = m_val.maybeGetMemberRef( childName ); if (childVal.isValid()) { BaseViewItem* childItem = factory->CreateViewItem( childName, toVariant( childVal ), NULL ); if (childItem != NULL) { int index = m_childNames.size(); m_childNames.push_back( childName ); connectChild( index, childItem ); items.push_back( childItem ); } } } } catch (FabricCore::Exception e) { const char* error = e.getDesc_cstr(); printf( error ); } }