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