1 // File: GeomValidators_ValidatorPositive.cpp
2 // Created: 16 Sep 2014
3 // Author: Mikhail PONIKAROV
5 #include "GeomValidators_Positive.h"
6 #include <ModelAPI_AttributeDouble.h>
7 #include <ModelAPI_Session.h>
8 #include <ModelAPI_Validator.h>
10 /// Global instance for validators factory
11 GeomValidators_Positive MY_POSITIVE_INSTANCE;
13 GeomValidators_Positive::GeomValidators_Positive()
15 // this validator is registered in the factory on this library loading
16 SessionPtr aMgr = ModelAPI_Session::get();
17 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
18 aFactory->registerValidator("GeomValidators_Positive", this);
21 bool GeomValidators_Positive::isValid(
22 const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
24 std::shared_ptr<ModelAPI_AttributeDouble> aDouble =
25 std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
26 return aDouble->isInitialized() && aDouble->value() > 1.e-5;