1 // File: ModelAPI_Data.hxx
2 // Created: 21 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Data_H_
6 #define ModelAPI_Data_H_
11 #include <boost/shared_ptr.hpp>
13 class ModelAPI_AttributeDocRef;
14 class ModelAPI_AttributeInteger;
15 class ModelAPI_AttributeDouble;
16 class ModelAPI_AttributeReference;
17 class ModelAPI_AttributeRefAttr;
18 class ModelAPI_AttributeRefList;
19 class ModelAPI_AttributeBoolean;
20 class ModelAPI_AttributeString;
21 class ModelAPI_Document;
22 class ModelAPI_Attribute;
23 class ModelAPI_Feature;
24 class ModelAPI_AttributeSelection;
25 class ModelAPI_AttributeSelectionList;
28 /**\class ModelAPI_Data
30 * \brief General object of the application that allows
31 * to get/set attributes from the document and compute result of an operation.
34 class MODELAPI_EXPORT ModelAPI_Data
38 /// Returns the name of the feature visible by the user in the object browser
39 virtual std::string name() = 0;
41 /// Defines the name of the feature visible by the user in the object browser
42 virtual void setName(const std::string& theName) = 0;
44 /// Returns the attribute that references to another document
45 virtual boost::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID) = 0;
46 /// Returns the attribute that contains real value with double precision
47 virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID) = 0;
48 /// Returns the attribute that contains integer value
49 virtual boost::shared_ptr<ModelAPI_AttributeInteger> integer(const std::string& theID) = 0;
50 /// Returns the attribute that contains reference to a feature
51 virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID) = 0;
52 /// Returns the attribute that contains selection to a shape
53 virtual boost::shared_ptr<ModelAPI_AttributeSelection> selection(const std::string& theID) = 0;
54 /// Returns the attribute that contains selection to a shape
55 virtual boost::shared_ptr<ModelAPI_AttributeSelectionList>
56 selectionList(const std::string& theID) = 0;
57 /// Returns the attribute that contains reference to an attribute of a feature
58 virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID) = 0;
59 /// Returns the attribute that contains list of references to features
60 virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID) = 0;
61 /// Returns the attribute that contains boolean value
62 virtual boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
63 /// Returns the attribute that contains boolean value
64 virtual boost::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID) = 0;
66 /// Returns the generic attribute by identifier
67 /// \param theID identifier of the attribute
68 virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID) = 0;
69 /// Returns all attributes of the feature of the given type
70 /// or all attributes if "theType" is empty
71 virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
72 attributes(const std::string& theType) = 0;
73 /// Returns all attributes ids of the feature of the given type
74 /// or all attributes if "theType" is empty
75 virtual std::list<std::string> attributesIDs(const std::string& theType) = 0;
76 /// Identifier by the id (not fast, iteration by map)
77 /// \param theAttr attribute already created in this data
78 virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr) = 0;
79 /// Returns true if data belongs to same features
80 virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data>& theData) = 0;
81 /// Returns true if it is correctly connected to the data model
82 virtual bool isValid() = 0;
84 /// Initializes object by the attributes: must be called just after the object is created
85 /// for each attribute of the object
86 /// \param theID identifier of the attribute that can be referenced by this ID later
87 /// \param theAttrType type of the created attribute (received from the type method)
88 virtual void addAttribute(const std::string& theID, const std::string theAttrType) = 0;
90 /// Useful method for "set" methods of the attributes: sends an UPDATE event and
91 /// makes attribute initialized
92 virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr) = 0;
94 /// Erases all the data from the data model
95 virtual void erase() = 0;
97 /// To virtually destroy the fields of successors
98 virtual ~ModelAPI_Data()
102 /// Makes feature must be updated later (on rebuild). Normally the Updater must call it
103 /// in case of not-automatic update to true
104 virtual void mustBeUpdated(const bool theFlag) = 0;
106 /// Returns true if feature must be updated (re-executed) on rebuild
107 virtual bool mustBeUpdated() = 0;
109 /// Returns the identifier of feature-owner, unique in this document
110 virtual int featureId() const = 0;
113 /// Objects are created for features automatically
119 typedef boost::shared_ptr<ModelAPI_Data> DataPtr;