1 // Name : ModelHighAPI_Interface.cpp
5 // 17/05/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Interface.h"
9 //--------------------------------------------------------------------------------------
10 #include <Events_InfoMessage.h>
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Session.h>
14 #include <ModelAPI_Validator.h>
16 #include "ModelHighAPI_Selection.h"
17 //--------------------------------------------------------------------------------------
18 ModelHighAPI_Interface::ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature)
19 : myFeature(theFeature)
24 ModelHighAPI_Interface::~ModelHighAPI_Interface()
29 //--------------------------------------------------------------------------------------
30 std::shared_ptr<ModelAPI_Feature> ModelHighAPI_Interface::feature() const
35 const std::string& ModelHighAPI_Interface::getKind() const
37 return feature()->getKind();
40 void ModelHighAPI_Interface::execute()
42 SessionPtr aMgr = ModelAPI_Session::get();
43 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
44 FeaturePtr aFeature = feature();
45 if(aFactory->validate(aFeature)) {
50 void ModelHighAPI_Interface::setName(const std::string& theName)
52 feature()->data()->setName(theName);
55 std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::result() const
57 // TODO(spo): should I use more common function for the whole model to prepare results?
58 const_cast<ModelHighAPI_Interface*>(this)->execute();
60 std::list<ModelHighAPI_Selection> aSelectionList;
62 std::list<std::shared_ptr<ModelAPI_Result> > aResults = feature()->results();
63 for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) {
64 aSelectionList.push_back(ModelHighAPI_Selection(*it));
67 return aSelectionList;
70 std::shared_ptr<ModelAPI_Result> ModelHighAPI_Interface::defaultResult() const
72 const_cast<ModelHighAPI_Interface*>(this)->execute();
74 return feature()->lastResult();
77 void ModelHighAPI_Interface::throwException(const std::string & theDescription)
79 Events_InfoMessage("ModelHighAPI_Interface", theDescription).send();
82 const std::string& ModelHighAPI_Interface::attributeGetter(const std::string& theAttrName)
84 return myAttrGetter[theAttrName];