]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_Data.h
Salome HOME
0cb633666de769388f272733148f6962dd47afed
[modules/shaper.git] / src / Model / Model_Data.h
1 // File:        Model_Data.hxx
2 // Created:     21 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Data_HeaderFile
6 #define Model_Data_HeaderFile
7
8 #include "Model.h"
9 #include <ModelAPI_Data.h>
10 #include <TDF_Label.hxx>
11
12 #include <map>
13
14 class ModelAPI_Attribute;
15 class ModelAPI_Feature;
16
17 /**\class Model_Data
18  * \ingroup DataModel
19  * \brief General object of the application that allows
20  * to get/set attributes from the document and compute result of an operation.
21  */
22
23 class Model_Data: public ModelAPI_Data
24 {
25   TDF_Label myLab; ///< label of the feature in the document
26   /// All attributes of the object identified by the attribute ID
27   std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> > myAttrs;
28
29   /// needed here to emit signal that feature changed on change of the attribute
30   boost::shared_ptr<ModelAPI_Feature> myFeature;
31
32   Model_Data();
33
34   TDF_Label label() {return myLab;}
35
36   friend class Model_Document;
37
38 public:
39   /// Returns the name of the feature visible by the user in the object browser
40   MODEL_EXPORT virtual std::string getName();
41   /// Defines the name of the feature visible by the user in the object browser
42   MODEL_EXPORT virtual void setName(std::string theName);
43   /// Returns the attribute that references to another document
44   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
45   /// Returns the attribute that contains real value with double precision
46   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
47   /// Returns the generic attribute by identifier
48   /// \param theID identifier of the attribute
49   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID);
50
51   /// Initializes object by the attributes: must be called just after the object is created
52   /// for each attribute of the object
53   /// \param theID identifier of the attribute that can be referenced by this ID later
54   /// \param theAttrType type of the created attribute (received from the type method)
55   MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
56
57   /// Puts feature to the document data sub-structure
58   MODEL_EXPORT void setLabel(TDF_Label& theLab);
59
60   /// Sets the feature of this data
61   MODEL_EXPORT virtual void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
62     {myFeature = theFeature;}
63 };
64
65 #endif