CValidatedUnit CEvaluationNodeCall::getUnit(const CMathContainer & math, const std::vector< CValidatedUnit > & units) const { CEvaluationTree * pTree = NULL; switch (mSubType) { case S_FUNCTION: pTree = mpFunction; break; case S_EXPRESSION: pTree = mpExpression; break; default: return CValidatedUnit(); break; } CUnitValidator Validator(math, *pTree); Validator.validateUnits(CValidatedUnit(CBaseUnit::undefined, false), units); return Validator.getUnit(); }
bool VerifyAnimationRename( UWidgetBlueprint* Blueprint, UWidgetAnimation* Animation, FString NewAnimationName, FText& OutErrorMessage ) { if ( FindObject<UWidgetAnimation>( Blueprint, *NewAnimationName, true ) ) { OutErrorMessage = LOCTEXT( "NameInUseByAnimation", "An animation with this name already exists" ); return false; } FName NewAnimationNameAsName( *NewAnimationName ); if ( Blueprint->WidgetTree->FindWidget<UWidget>( NewAnimationNameAsName ) != nullptr ) { OutErrorMessage = LOCTEXT( "NameInUseByWidget", "A widget with this name already exists" ); return false; } FName FunctionName(*NewAnimationName); if (Animation->GetPreviewWidget().IsValid() && Animation->GetPreviewWidget().Get()->FindFunction(FunctionName)) { OutErrorMessage = LOCTEXT("NameInUseByFunction", "A function with this name already exists"); return false; } FKismetNameValidator Validator( Blueprint ); EValidatorResult ValidationResult = Validator.IsValid( NewAnimationName ); if ( ValidationResult != EValidatorResult::Ok ) { FString ErrorString = FKismetNameValidator::GetErrorString( NewAnimationName, ValidationResult ); OutErrorMessage = FText::FromString( ErrorString ); return false; } return true; }
bool Hierarchy::get_is_valid(bool print_info) const { try { IMP::core::visit_depth_first_with_data(*this, Validator(print_info), false); } catch (const BadHierarchy &) { return false; } return true; }
// Only public function of the module void apply_style(XMLDocument const & xml, XMLDocument const & xsl, std::ostream & out, std::ostream & err) { if (Validator(*xsl.root(), err)()) { Document xsl_doc(xsl); xsl_doc.apply_style_to(xml, out); } }
// virtual CValidatedUnit CEvaluationNodeCall::setUnit(const CMathContainer & container, const std::map < CEvaluationNode *, CValidatedUnit > & currentUnits, std::map < CEvaluationNode *, CValidatedUnit > & targetUnits) const { CEvaluationTree * pTree = NULL; switch (mSubType) { case S_FUNCTION: pTree = mpFunction; break; case S_EXPRESSION: pTree = mpExpression; break; default: return CValidatedUnit(); break; } // Retrieve the current units of the variables std::vector< CEvaluationNode * >::const_iterator it = mCallNodes.begin(); std::vector< CEvaluationNode * >::const_iterator end = mCallNodes.end(); std::vector< CValidatedUnit > CurrentVariableUnits(mCallNodes.size()); std::vector< CValidatedUnit >::iterator itUnit = CurrentVariableUnits.begin(); for (; it != end; ++it, ++itUnit) { *itUnit = currentUnits.find(const_cast< CEvaluationNode * >(*it))->second; } CUnitValidator Validator(container, *pTree); Validator.validateUnits(CValidatedUnit::merge(currentUnits.find(const_cast< CEvaluationNodeCall * >(this))->second, targetUnits[const_cast< CEvaluationNodeCall * >(this)]), CurrentVariableUnits); std::vector< CValidatedUnit >::const_iterator itValidatedVariableUnit = Validator.getVariableUnits().begin(); for (it = mCallNodes.begin(); it != end; ++it, ++itValidatedVariableUnit) { std::map < CEvaluationNode * , CValidatedUnit >::iterator found = targetUnits.find(const_cast< CEvaluationNode * >(*it)); if (found == targetUnits.end()) { found = targetUnits.insert(std::make_pair(const_cast< CEvaluationNode * >(*it), CValidatedUnit(CBaseUnit::undefined, false))).first; } found->second = CValidatedUnit::merge(found->second, *itValidatedVariableUnit); } return Validator.getUnit(); }
track PTracker::createTrack( detection& det, IdGenerator& idGenerator, Mat& grayFrame) { auto track = createFromDetection(det, idGenerator, grayFrame); track.markedForDeletion = false; tracks.push_back(track); auto filter = shared_ptr<KalmanFilter2D>(new KalmanFilter2D()); KalmanInput2D input = {det.rect}; filter->init(input); kalmanFilters[track.id] = filter; Validator v = Validator(); validators[track.id] = v; validators[track.id].tick(true); return track; }
TEST(ValidatorTest, NoOptions) { ASSERT_VELOCYPACK_EXCEPTION(Validator(nullptr), Exception::InternalError); }