Salome HOME
Define guards are corrected according to the code style
[modules/shaper.git] / src / ModelAPI / ModelAPI_Data.h
1 // File:        ModelAPI_Data.hxx
2 // Created:     21 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef ModelAPI_Data_H_
6 #define ModelAPI_Data_H_
7
8 #include "ModelAPI.h"
9 #include <string>
10 #include <list>
11 #include <boost/shared_ptr.hpp>
12
13 class ModelAPI_AttributeDocRef;
14 class ModelAPI_AttributeDouble;
15 class ModelAPI_AttributeReference;
16 class ModelAPI_AttributeRefAttr;
17 class ModelAPI_AttributeRefList;
18 class ModelAPI_AttributeBoolean;
19 class ModelAPI_Document;
20 class ModelAPI_Attribute;
21 class GeomAPI_Shape;
22
23 /**\class ModelAPI_Data
24  * \ingroup DataModel
25  * \brief General object of the application that allows
26  * to get/set attributes from the document and compute result of an operation.
27  */
28
29 class MODELAPI_EXPORT ModelAPI_Data
30 {
31 public:
32
33   /// Returns the name of the feature visible by the user in the object browser
34   virtual std::string name() = 0;
35
36   /// Defines the name of the feature visible by the user in the object browser
37   virtual void setName(const std::string& theName) = 0;
38
39   /// Returns the attribute that references to another document
40   virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string& theID) = 0;
41   /// Returns the attribute that contains real value with double precision
42   virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID) = 0;
43   /// Returns the attribute that contains reference to a feature
44   virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID) = 0;
45   /// Returns the attribute that contains reference to an attribute of a feature
46   virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID) = 0;
47   /// Returns the attribute that contains list of references to features
48   virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID) = 0;
49   /// Returns the attribute that contains boolean value
50   virtual boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
51
52   /// Returns the generic attribute by identifier
53   /// \param theID identifier of the attribute
54   virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID) = 0;
55   /// Returns all attributes ofthe feature of the given type
56   /// or all attributes if "theType" is empty
57   virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
58     attributes(const std::string& theType) = 0;
59   /// Identifier by the id (not fast, iteration by map)
60   /// \param theAttr attribute already created in this data
61   virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr) = 0;
62   /// Returns true if data belongs to same features
63   virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data>& theData) = 0;
64   /// Returns true if it is correctly connected to the data model
65   virtual bool isValid() = 0;
66
67   /// Initializes object by the attributes: must be called just after the object is created
68   /// for each attribute of the object
69   /// \param theID identifier of the attribute that can be referenced by this ID later
70   /// \param theAttrType type of the created attribute (received from the type method)
71   virtual void addAttribute(const std::string& theID, const std::string theAttrType) = 0;
72
73   /// Useful method for "set" methods of the attributes: sends an UPDATE event and
74   /// makes attribute initialized
75   virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr) = 0;
76
77   /// To virtually destroy the fields of successors
78   virtual ~ModelAPI_Data() {}
79
80 protected:
81   /// Objects are created for features automatically
82   ModelAPI_Data()
83   {}
84 };
85
86 typedef boost::shared_ptr<ModelAPI_Data> DataPtr;
87
88
89 #endif