1 // Name : ModelHighAPI_Interface.h
5 // 17/05/16 - Sergey POKHODENKO - Creation of the file
7 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
8 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
10 //--------------------------------------------------------------------------------------
11 #include "ModelHighAPI.h"
18 //--------------------------------------------------------------------------------------
19 class ModelAPI_Feature;
20 class ModelAPI_Result;
21 class ModelHighAPI_Selection;
22 class ModelHighAPI_Dumper;
23 //--------------------------------------------------------------------------------------
24 /**\class ModelHighAPI_Interface
26 * \brief Base class for feature interfaces
28 class ModelHighAPI_Interface
33 explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
36 virtual ~ModelHighAPI_Interface();
38 /// Return ModelAPI_Feature
40 std::shared_ptr<ModelAPI_Feature> feature() const;
42 /// If feature is composite return intefrace for sub-feature by zero-based index,
43 /// or empty pointer if feature not composite or does not have sub-feature with such index.
45 std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
47 /// Shortcut for feature()->getKind()
49 const std::string& getKind() const;
51 /// Shortcut for feature()->execute()
55 /// Shortcut for feature()->data()->setName()
57 void setName(const std::string& theName);
59 // TODO(spo): rename to selectAll()
60 /// Return all objects of the feature
62 virtual std::list<ModelHighAPI_Selection> result() const;
64 /// Return default result. Default implementation feature()->lastResult()
66 virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
68 /// Throw exception to event loop
70 void throwException(const std::string & theDescription);
72 /// Return name of getter for specified attribute
74 const std::string& attributeGetter(const std::string& theAttrName);
76 /// Dump wrapped feature
78 virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
81 std::shared_ptr<ModelAPI_Feature> myFeature;
83 std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
86 //! Pointer on Interface object
87 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
89 //--------------------------------------------------------------------------------------
90 //--------------------------------------------------------------------------------------
91 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */