1 // File: Model_Data.hxx
2 // Created: 21 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef Model_Data_HeaderFile
6 #define Model_Data_HeaderFile
9 #include <ModelAPI_Data.h>
10 #include <TDF_Label.hxx>
14 class ModelAPI_Attribute;
15 class ModelAPI_Feature;
19 * \brief General object of the application that allows
20 * to get/set attributes from the document and compute result of an operation.
23 class Model_Data: public ModelAPI_Data
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;
29 /// needed here to emit signal that feature changed on change of the attribute
30 boost::shared_ptr<ModelAPI_Feature> myFeature;
34 /// Returns label of this feature
35 TDF_Label label() {return myLab;}
37 friend class Model_Document;
38 friend class Model_AttributeReference;
39 friend class Model_AttributeRefAttr;
42 /// Returns the name of the feature visible by the user in the object browser
43 MODEL_EXPORT virtual std::string getName();
44 /// Defines the name of the feature visible by the user in the object browser
45 MODEL_EXPORT virtual void setName(std::string theName);
46 /// Returns the attribute that references to another document
47 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
48 /// Returns the attribute that contains real value with double precision
49 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
50 /// Returns the attribute that contains reference to a feature
51 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeReference>
52 reference(const std::string theID);
53 /// Returns the attribute that contains reference to an attribute of a feature
54 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefAttr>
55 refattr(const std::string theID);
56 /// Returns the generic attribute by identifier
57 /// \param theID identifier of the attribute
58 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID);
59 /// Identifier by the id (not fast, iteration by map)
60 /// \param theAttr attribute already created in this data
61 MODEL_EXPORT virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute> theAttr);
63 /// Initializes object by the attributes: must be called just after the object is created
64 /// for each attribute of the object
65 /// \param theID identifier of the attribute that can be referenced by this ID later
66 /// \param theAttrType type of the created attribute (received from the type method)
67 MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
69 /// Puts feature to the document data sub-structure
70 MODEL_EXPORT void setLabel(TDF_Label& theLab);
72 /// Sets the feature of this data
73 MODEL_EXPORT virtual void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
74 {myFeature = theFeature;}