Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Interface.h
1 // Name   : ModelHighAPI_Interface.h
2 // Purpose: 
3 //
4 // History:
5 // 17/05/16 - Sergey POKHODENKO - Creation of the file
6
7 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
8 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
9
10 //--------------------------------------------------------------------------------------
11 #include "ModelHighAPI.h"
12
13 #include <list>
14 #include <map>
15 #include <memory>
16 #include <string>
17 #include <iostream>
18 //--------------------------------------------------------------------------------------
19 class ModelAPI_Feature;
20 class ModelAPI_Result;
21 class ModelHighAPI_Selection;
22 class ModelHighAPI_Dumper;
23 //--------------------------------------------------------------------------------------
24 /**\class ModelHighAPI_Interface
25  * \ingroup CPPHighAPI
26  * \brief Base class for feature interfaces
27  */
28 class ModelHighAPI_Interface
29 {
30 public:
31   /// Constructor
32   MODELHIGHAPI_EXPORT
33   explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
34   /// Destructor
35   MODELHIGHAPI_EXPORT
36   virtual ~ModelHighAPI_Interface();
37
38   /// Return ModelAPI_Feature
39   MODELHIGHAPI_EXPORT
40   std::shared_ptr<ModelAPI_Feature> feature() const;
41
42   /// Shortcut for feature()->getKind()
43   MODELHIGHAPI_EXPORT
44   const std::string& getKind() const;
45
46   /// Shortcut for feature()->execute()
47   MODELHIGHAPI_EXPORT
48   void execute();
49
50   /// Shortcut for feature()->data()->setName()
51   MODELHIGHAPI_EXPORT
52   void setName(const std::string& theName);
53
54   // TODO(spo): rename to selectAll()
55   /// Return all objects of the feature
56   MODELHIGHAPI_EXPORT
57   virtual std::list<ModelHighAPI_Selection> result() const;
58
59   /// Return default result. Default implementation feature()->lastResult()
60   MODELHIGHAPI_EXPORT
61   virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
62
63   /// Throw exception to event loop
64   MODELHIGHAPI_EXPORT
65   void throwException(const std::string & theDescription);
66
67   /// Return name of getter for specified attribute
68   MODELHIGHAPI_EXPORT
69   const std::string& attributeGetter(const std::string& theAttrName);
70
71   /// Dump wrapped feature
72   MODELHIGHAPI_EXPORT
73   virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
74
75 protected:
76   std::shared_ptr<ModelAPI_Feature> myFeature;
77
78   std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
79 };
80
81 //! Pointer on Interface object
82 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
83
84 //--------------------------------------------------------------------------------------
85 //--------------------------------------------------------------------------------------
86 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */