]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_Interface.h
Salome HOME
Issue #2052: Modification of parameters don't work (sketch, extrusion)
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Interface.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name   : ModelHighAPI_Interface.h
3 // Purpose:
4 //
5 // History:
6 // 17/05/16 - Sergey POKHODENKO - Creation of the file
7
8 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
9 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
10
11 //--------------------------------------------------------------------------------------
12 #include "ModelHighAPI.h"
13
14 #include <list>
15 #include <map>
16 #include <memory>
17 #include <string>
18 #include <iostream>
19 //--------------------------------------------------------------------------------------
20 class ModelAPI_Feature;
21 class ModelAPI_Result;
22 class ModelHighAPI_Selection;
23 class ModelHighAPI_Dumper;
24 //--------------------------------------------------------------------------------------
25 /**\class ModelHighAPI_Interface
26  * \ingroup CPPHighAPI
27  * \brief Base class for feature interfaces
28  */
29 class ModelHighAPI_Interface
30 {
31 public:
32   /// Constructor
33   MODELHIGHAPI_EXPORT
34   explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
35   /// Destructor
36   MODELHIGHAPI_EXPORT
37   virtual ~ModelHighAPI_Interface();
38
39   /// Return ModelAPI_Feature
40   MODELHIGHAPI_EXPORT
41   std::shared_ptr<ModelAPI_Feature> feature() const;
42
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.
45   MODELHIGHAPI_EXPORT
46   std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
47
48   /// Shortcut for feature()->getKind()
49   MODELHIGHAPI_EXPORT
50   const std::string& getKind() const;
51
52   /// Shortcut for feature()->execute()
53   /// \param isForce start execution of feature instead of sending events
54   MODELHIGHAPI_EXPORT
55   void execute(bool isForce = false);
56
57   /// Shortcut for feature()->data()->setName()
58   MODELHIGHAPI_EXPORT
59   void setName(const std::string& theName);
60
61   /// Return firts object of the feature
62   MODELHIGHAPI_EXPORT
63   virtual ModelHighAPI_Selection result() const;
64
65   /// Return all objects of the feature
66   MODELHIGHAPI_EXPORT
67   virtual std::list<ModelHighAPI_Selection> results() const;
68
69   /// Return default result. Default implementation feature()->lastResult()
70   MODELHIGHAPI_EXPORT
71   virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
72
73   /// Throw exception to event loop
74   MODELHIGHAPI_EXPORT
75   void throwException(const std::string & theDescription);
76
77   /// Return name of getter for specified attribute
78   MODELHIGHAPI_EXPORT
79   const std::string& attributeGetter(const std::string& theAttrName);
80
81   /// Dump wrapped feature
82   MODELHIGHAPI_EXPORT
83   virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
84
85 protected:
86   std::shared_ptr<ModelAPI_Feature> myFeature; ///< feature of this interface
87
88   std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
89 };
90
91 //! Pointer on Interface object
92 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
93
94 //--------------------------------------------------------------------------------------
95 //--------------------------------------------------------------------------------------
96 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */