Salome HOME
Fixed the crash on moving Group down and edit it in the issue #1862
[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 all objects of the feature
62   MODELHIGHAPI_EXPORT
63   virtual std::list<ModelHighAPI_Selection> result() const;
64
65   /// Return default result. Default implementation feature()->lastResult()
66   MODELHIGHAPI_EXPORT
67   virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
68
69   /// Throw exception to event loop
70   MODELHIGHAPI_EXPORT
71   void throwException(const std::string & theDescription);
72
73   /// Return name of getter for specified attribute
74   MODELHIGHAPI_EXPORT
75   const std::string& attributeGetter(const std::string& theAttrName);
76
77   /// Dump wrapped feature
78   MODELHIGHAPI_EXPORT
79   virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
80
81 protected:
82   std::shared_ptr<ModelAPI_Feature> myFeature; ///< feature of this interface
83
84   std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
85 };
86
87 //! Pointer on Interface object
88 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
89
90 //--------------------------------------------------------------------------------------
91 //--------------------------------------------------------------------------------------
92 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */