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