1 // File: ModelAPI_Data.hxx
2 // Created: 21 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Data_HeaderFile
6 #define ModelAPI_Data_HeaderFile
10 #include <boost/shared_ptr.hpp>
12 class ModelAPI_AttributeDocRef;
13 class ModelAPI_AttributeDouble;
14 class ModelAPI_AttributeReference;
15 class ModelAPI_AttributeRefAttr;
16 class ModelAPI_AttributeRefList;
17 class ModelAPI_Document;
18 class ModelAPI_Attribute;
20 /**\class ModelAPI_Data
22 * \brief General object of the application that allows
23 * to get/set attributes from the document and compute result of an operation.
26 class MODELAPI_EXPORT ModelAPI_Data
30 /// Returns the name of the feature visible by the user in the object browser
31 virtual std::string getName() = 0;
33 /// Defines the name of the feature visible by the user in the object browser
34 virtual void setName(std::string theName) = 0;
36 /// Returns the attribute that references to another document
37 virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID) = 0;
38 /// Returns the attribute that contains real value with double precision
39 virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID) = 0;
40 /// Returns the attribute that contains reference to a feature
41 virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string theID) = 0;
42 /// Returns the attribute that contains reference to an attribute of a feature
43 virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string theID) = 0;
44 /// Returns the attribute that contains list of references to features
45 virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string theID) = 0;
47 /// Returns the generic attribute by identifier
48 /// \param theID identifier of the attribute
49 virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID) = 0;
50 /// Identifier by the id (not fast, iteration by map)
51 /// \param theAttr attribute already created in this data
52 virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute> theAttr) = 0;
53 /// Returns true if data belongs to same features
54 virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data> theData) = 0;
55 /// Returns true if it is correctly connected t othe data model
56 virtual bool isValid() = 0;
58 /// Initializes object by the attributes: must be called just after the object is created
59 /// for each attribute of the object
60 /// \param theID identifier of the attribute that can be referenced by this ID later
61 /// \param theAttrType type of the created attribute (received from the type method)
62 virtual void addAttribute(std::string theID, std::string theAttrType) = 0;
64 /// To virtually destroy the fields of successors
65 virtual ~ModelAPI_Data() {}
68 /// Objects are created for features automatically
73 typedef boost::shared_ptr<ModelAPI_Data> DataPtr;