1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : ModelHighAPI_Interface.h
6 // 17/05/16 - Sergey POKHODENKO - Creation of the file
8 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
9 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
11 //--------------------------------------------------------------------------------------
12 #include "ModelHighAPI.h"
19 //--------------------------------------------------------------------------------------
20 class ModelAPI_Feature;
21 class ModelAPI_Result;
22 class ModelHighAPI_Selection;
23 class ModelHighAPI_Dumper;
24 //--------------------------------------------------------------------------------------
25 /**\class ModelHighAPI_Interface
27 * \brief Base class for feature interfaces
29 class ModelHighAPI_Interface
34 explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
37 virtual ~ModelHighAPI_Interface();
39 /// Return ModelAPI_Feature
41 std::shared_ptr<ModelAPI_Feature> feature() const;
43 /// If feature is composite return intefrace for sub-feature by zero-based index,
44 /// or empty pointer if feature not composite or does not have sub-feature with such index.
46 std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
48 /// Shortcut for feature()->getKind()
50 const std::string& getKind() const;
52 /// Shortcut for feature()->execute()
53 /// \param isForce start execution of feature instead of sending events
55 void execute(bool isForce = false);
57 /// Shortcut for feature()->data()->setName()
59 void setName(const std::string& theName);
61 // TODO(spo): rename to selectAll()
62 /// Return all objects of the feature
64 virtual std::list<ModelHighAPI_Selection> result() const;
66 /// Return default result. Default implementation feature()->lastResult()
68 virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
70 /// Throw exception to event loop
72 void throwException(const std::string & theDescription);
74 /// Return name of getter for specified attribute
76 const std::string& attributeGetter(const std::string& theAttrName);
78 /// Dump wrapped feature
80 virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
83 std::shared_ptr<ModelAPI_Feature> myFeature; ///< feature of this interface
85 std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
88 //! Pointer on Interface object
89 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
91 //--------------------------------------------------------------------------------------
92 //--------------------------------------------------------------------------------------
93 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */