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 std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::result() const
52 // TODO(spo): should I use more common function for the whole model to prepare results?
53 const_cast<ModelHighAPI_Interface*>(this)->execute();
55 std::list<ModelHighAPI_Selection> aSelectionList;
57 std::list<std::shared_ptr<ModelAPI_Result> > aResults = feature()->results();
58 for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) {
59 aSelectionList.push_back(ModelHighAPI_Selection(*it));
62 return aSelectionList;
65 std::shared_ptr<ModelAPI_Result> ModelHighAPI_Interface::defaultResult() const
67 const_cast<ModelHighAPI_Interface*>(this)->execute();
69 return feature()->lastResult();
72 void ModelHighAPI_Interface::throwException(const std::string & theDescription)
74 Events_InfoMessage("ModelHighAPI_Interface", theDescription).send();
77 const std::string& ModelHighAPI_Interface::attributeGetter(const std::string& theAttrName)
79 return myAttrGetter[theAttrName];