void Analysis_Impl::clearAlgorithm() { if (m_algorithm) { disconnectChild(*m_algorithm); m_algorithm.reset(); onChange(AnalysisObject_Impl::Benign); } }
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; }
void MeasureGroup_Impl::clearMeasures() { for (Measure& measure : m_measures) { disconnectChild(measure); } m_measures.clear(); onChange(AnalysisObject_Impl::InvalidatesDataPoints); }
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 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; }
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; }
bool Analysis_Impl::removeDataPoint(const DataPoint &dataPoint) { OptionalDataPoint exactDataPoint = getDataPointByUUID(dataPoint); if (exactDataPoint) { DataPointVector::iterator it = std::find(m_dataPoints.begin(),m_dataPoints.end(),*exactDataPoint); OS_ASSERT(it != m_dataPoints.end()); disconnectChild(*it); m_dataPoints.erase(it); // TODO: It may be that the algorithm should be reset, or at least marked not-complete. if (m_dataPoints.empty()) { m_resultsAreInvalid = false; m_dataPointsAreInvalid = false; } onChange(AnalysisObject_Impl::Benign); return true; } return false; }
bool MeasureGroup_Impl::erase(const Measure& measure) { auto it = std::find_if( m_measures.begin(), m_measures.end(), std::bind(uuidsEqual<Measure,Measure>,std::placeholders::_1,measure)); if (it == m_measures.end()) { return false; } int index = int(it - m_measures.begin()); disconnectChild(*it); m_measures.erase(it); for (int i = index, n = int(m_measures.size()); i < n; ++i) { m_measures[i].onChange(); } onChange(AnalysisObject_Impl::InvalidatesDataPoints); return true; }
BOOST_FOREACH(DataPoint& dataPoint, m_dataPoints) { disconnectChild(dataPoint); }
/* * Remove one node from BBST specified by node. The BST is also rotated if after * removal the balance is broken. Once the BBST is updated (at least one node is * deleted/inserted), the iterater is expired. */ int removeBBSTNode(BBST tree, BBSTNode *pnode) { BBSTNode node = NULL; BBSTNode parent = NULL; BBSTNode toremove = NULL; BBSTNode p = NULL; Assert( tree != NULL ); Assert( tree->Root != NULL ); Assert( (*pnode) != NULL ); node = *pnode; parent = node->Parent; /* Check if the node is in the tree。 */ if( getHASHTABLENode(tree->NodeIndex, node->Data) == NULL ) { return UTIL_BBST_NOT_IN_THIS_TREE; } if ( tree->Root == node ) { /* If we have only one node in the tree, it must be the one to remove.*/ if ( tree->Root->NodeCount == 1 ) { tree->Root = NULL; clearHASHTABLE(tree->NodeIndex); return FUNC_RETURN_OK; } else if ( tree->Root->Right == NULL && tree->Root->Left != NULL) { tree->Root = node->Left; tree->Root->Parent = NULL; removeHASHTABLENode(tree->NodeIndex, node->Data); node->Left = NULL; return FUNC_RETURN_OK; } else if ( tree->Root->Right != NULL && tree->Root->Left == NULL) { tree->Root = node->Right; tree->Root->Parent = NULL; removeHASHTABLENode(tree->NodeIndex, node->Data); node->Right = NULL; return FUNC_RETURN_OK; } } /* Remove the node */ /* Case 1: The leaf node to delete. */ if ( node->Left == NULL && node->Right == NULL ) { removeHASHTABLENode(tree->NodeIndex, node->Data); disconnectChild(parent, node); p = parent; shiftupCalculateChildCountAndDepth(p); rebalanceBBST(tree, parent); return FUNC_RETURN_OK; } /* Case 2.1: One branch node with only one left leaf node. */ else if ( node->Left != NULL && node->Right == NULL) { removeHASHTABLENode(tree->NodeIndex, node->Data); bool connleft = parent->Left == node ? true : false; disconnectChild(parent, node); if ( connleft ) { connectAsLeftChild(parent, node->Left); } else { connectAsRightChild(parent, node->Left); } p = parent; shiftupCalculateChildCountAndDepth(p); rebalanceBBST(tree, parent); node->Left = NULL; return FUNC_RETURN_OK; } /* Case 2.2: one branch node with only one right leaf node. */ else if ( node->Right != NULL && node->Left == NULL) { removeHASHTABLENode(tree->NodeIndex, node->Data); bool connleft = parent->Left == node ? true : false; disconnectChild(parent, node); if ( connleft ) { connectAsLeftChild(parent, node->Right); } else { connectAsRightChild(parent, node->Right); } p = parent; shiftupCalculateChildCountAndDepth(p); rebalanceBBST(tree, parent); node->Right = NULL; return FUNC_RETURN_OK; } /* * Case 3: one branch node with two leaf nodes.We choose the right most leaf * node in the left child tree to replace the node to delete. toremove saves * the node to actually be removed in BBST. This is done by recursively call * this function again. In this case,the node toremove has at most one child * tree. The recursion depth is only 2.Thus,No need to worry about the stack * overflow. */ toremove = node->Left; while( toremove->Right != NULL ) { toremove = toremove->Right; } void *tmpval = node->Data; node->Data = toremove->Data; toremove->Data = tmpval; setHASHTABLENode(tree->NodeIndex, toremove->Data, toremove, false); setHASHTABLENode(tree->NodeIndex, node->Data, node, false); *pnode = toremove; return removeBBSTNode(tree, pnode); }