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 /// Return firts object of the feature
63 virtual ModelHighAPI_Selection result() const;
65 /// Return all objects of the feature
67 virtual std::list<ModelHighAPI_Selection> results() const;
69 /// Return default result. Default implementation feature()->lastResult()
71 virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
73 /// Throw exception to event loop
75 void throwException(const std::string & theDescription);
77 /// Return name of getter for specified attribute
79 const std::string& attributeGetter(const std::string& theAttrName);
81 /// Dump wrapped feature
83 virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
86 std::shared_ptr<ModelAPI_Feature> myFeature; ///< feature of this interface
88 std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
91 //! Pointer on Interface object
92 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
94 //--------------------------------------------------------------------------------------
95 //--------------------------------------------------------------------------------------
96 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */