1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomValidators_ValidatorPositive.cpp
4 // Created: 16 Sep 2014
5 // Author: Mikhail PONIKAROV
7 #include "GeomValidators_Positive.h"
8 #include <ModelAPI_AttributeDouble.h>
9 #include <ModelAPI_Session.h>
10 #include <ModelAPI_Validator.h>
12 /// Global instance for validators factory
13 GeomValidators_Positive MY_POSITIVE_INSTANCE;
15 GeomValidators_Positive::GeomValidators_Positive()
17 // this validator is registered in the factory on this library loading
18 SessionPtr aMgr = ModelAPI_Session::get();
19 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
20 aFactory->registerValidator("GeomValidators_Positive", this);
23 bool GeomValidators_Positive::isValid(
24 const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
26 std::shared_ptr<ModelAPI_AttributeDouble> aDouble =
27 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
28 return aDouble->isInitialized() && aDouble->value() > 1.e-5;