Salome HOME
Merge branch 'CPPHighAPI'
[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 <memory>
15 #include <string>
16 #include <iostream>
17 //--------------------------------------------------------------------------------------
18 class ModelAPI_Feature;
19 class ModelAPI_Result;
20 class ModelHighAPI_Selection;
21 //--------------------------------------------------------------------------------------
22 /**\class ModelHighAPI_Interface
23  * \ingroup CPPHighAPI
24  * \brief Base class for feature interfaces
25  */
26 class ModelHighAPI_Interface
27 {
28 public:
29   /// Constructor
30   MODELHIGHAPI_EXPORT
31   explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
32   /// Destructor
33   MODELHIGHAPI_EXPORT
34   virtual ~ModelHighAPI_Interface();
35
36   /// Return ModelAPI_Feature
37   MODELHIGHAPI_EXPORT
38   std::shared_ptr<ModelAPI_Feature> feature() const;
39
40   /// Shortcut for feature()->getKind()
41   MODELHIGHAPI_EXPORT
42   const std::string& getKind() const;
43
44   /// Shortcut for feature()->execute()
45   MODELHIGHAPI_EXPORT
46   void execute();
47
48   // TODO(spo): rename to selectAll()
49   /// Return all objects of the feature
50   MODELHIGHAPI_EXPORT
51   virtual std::list<ModelHighAPI_Selection> result() const;
52
53   /// Return default result. Default implementation feature()->lastResult()
54   MODELHIGHAPI_EXPORT
55   virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
56
57   /// Throw exception to event loop
58   MODELHIGHAPI_EXPORT
59   void throwException(const std::string & theDescription);
60
61 protected:
62   std::shared_ptr<ModelAPI_Feature> myFeature;
63 };
64
65 //! Pointer on Interface object
66 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
67
68 //--------------------------------------------------------------------------------------
69 //--------------------------------------------------------------------------------------
70 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */