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