]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/ModelAPI_Data.h
Salome HOME
1bd01c5b3692d1ab9fa97bcbe0edc21c0277b9c7
[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_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 GeomAPI_Shape;
26
27 /**\class ModelAPI_Data
28  * \ingroup DataModel
29  * \brief General object of the application that allows
30  * to get/set attributes from the document and compute result of an operation.
31  */
32
33 class MODELAPI_EXPORT ModelAPI_Data
34 {
35  public:
36
37   /// Returns the name of the feature visible by the user in the object browser
38   virtual std::string name() = 0;
39
40   /// Defines the name of the feature visible by the user in the object browser
41   virtual void setName(const std::string& theName) = 0;
42
43   /// Returns the attribute that references to another document
44   virtual boost::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID) = 0;
45   /// Returns the attribute that contains real value with double precision
46   virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID) = 0;
47   /// Returns the attribute that contains integer value
48   virtual boost::shared_ptr<ModelAPI_AttributeInteger> integer(const std::string& theID) = 0;
49   /// Returns the attribute that contains reference to a feature
50   virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID) = 0;
51   /// Returns the attribute that contains selection to a shape
52   virtual boost::shared_ptr<ModelAPI_AttributeSelection> selection(const std::string& theID) = 0;
53   /// Returns the attribute that contains reference to an attribute of a feature
54   virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID) = 0;
55   /// Returns the attribute that contains list of references to features
56   virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID) = 0;
57   /// Returns the attribute that contains boolean value
58   virtual boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
59   /// Returns the attribute that contains boolean value
60   virtual boost::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID) = 0;
61
62   /// Returns the generic attribute by identifier
63   /// \param theID identifier of the attribute
64   virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID) = 0;
65   /// Returns all attributes of the feature of the given type
66   /// or all attributes if "theType" is empty
67   virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
68   attributes(const std::string& theType) = 0;
69   /// Returns all attributes ids of the feature of the given type
70   /// or all attributes if "theType" is empty
71   virtual std::list<std::string> attributesIDs(const std::string& theType) = 0;
72   /// Identifier by the id (not fast, iteration by map)
73   /// \param theAttr attribute already created in this data
74   virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr) = 0;
75   /// Returns true if data belongs to same features
76   virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data>& theData) = 0;
77   /// Returns true if it is correctly connected to the data model
78   virtual bool isValid() = 0;
79
80   /// Initializes object by the attributes: must be called just after the object is created
81   /// for each attribute of the object
82   /// \param theID identifier of the attribute that can be referenced by this ID later
83   /// \param theAttrType type of the created attribute (received from the type method)
84   virtual void addAttribute(const std::string& theID, const std::string theAttrType) = 0;
85
86   /// Useful method for "set" methods of the attributes: sends an UPDATE event and
87   /// makes attribute initialized
88   virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr) = 0;
89
90   /// Erases all the data from the data model
91   virtual void erase() = 0;
92
93   /// To virtually destroy the fields of successors
94   virtual ~ModelAPI_Data()
95   {
96   }
97
98   /// Makes feature must be updated later (on rebuild). Normally the Updater must call it
99   /// in case of not-automatic update to true
100   virtual void mustBeUpdated(const bool theFlag) = 0;
101
102   /// Returns true if feature must be updated (re-executed) on rebuild
103   virtual bool mustBeUpdated() = 0;
104
105   /// Returns true if this data attributes are referenced to the given feature or its results
106   virtual bool referencesTo(const boost::shared_ptr<ModelAPI_Feature>& theFeature) = 0;
107
108  protected:
109   /// Objects are created for features automatically
110   ModelAPI_Data()
111   {
112   }
113 };
114
115 typedef boost::shared_ptr<ModelAPI_Data> DataPtr;
116
117 #endif