Salome HOME
Merge branch 'master' of newgeom:newgeom
[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_HeaderFile
6 #define ModelAPI_Data_HeaderFile
7
8 #include "ModelAPI.h"
9 #include <string>
10 #include <boost/shared_ptr.hpp>
11
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;
19 class GeomAPI_Shape;
20
21 /**\class ModelAPI_Data
22  * \ingroup DataModel
23  * \brief General object of the application that allows
24  * to get/set attributes from the document and compute result of an operation.
25  */
26
27 class MODELAPI_EXPORT ModelAPI_Data
28 {
29 public:
30
31   /// Returns the name of the feature visible by the user in the object browser
32   virtual std::string getName() = 0;
33
34   /// Defines the name of the feature visible by the user in the object browser
35   virtual void setName(std::string theName) = 0;
36
37   /// Returns the attribute that references to another document
38   virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID) = 0;
39   /// Returns the attribute that contains real value with double precision
40   virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID) = 0;
41   /// Returns the attribute that contains reference to a feature
42   virtual boost::shared_ptr<ModelAPI_AttributeReference> reference(const std::string theID) = 0;
43   /// Returns the attribute that contains reference to an attribute of a feature
44   virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string theID) = 0;
45   /// Returns the attribute that contains list of references to features
46   virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string theID) = 0;
47
48   /// Returns the generic attribute by identifier
49   /// \param theID identifier of the attribute
50   virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID) = 0;
51   /// Identifier by the id (not fast, iteration by map)
52   /// \param theAttr attribute already created in this data
53   virtual const std::string& id(const boost::shared_ptr<ModelAPI_Attribute> theAttr) = 0;
54   /// Returns true if data belongs to same features
55   virtual bool isEqual(const boost::shared_ptr<ModelAPI_Data> theData) = 0;
56   /// Returns true if it is correctly connected t othe data model
57   virtual bool isValid() = 0;
58
59   /// Stores the shape (called by the execution method).
60   virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape) = 0;
61   /// Returns the shape-result produced by this feature
62   virtual boost::shared_ptr<GeomAPI_Shape> shape() = 0;
63
64   /// Initializes object by the attributes: must be called just after the object is created
65   /// for each attribute of the object
66   /// \param theID identifier of the attribute that can be referenced by this ID later
67   /// \param theAttrType type of the created attribute (received from the type method)
68   virtual void addAttribute(std::string theID, std::string theAttrType) = 0;
69
70   /// To virtually destroy the fields of successors
71   virtual ~ModelAPI_Data() {}
72
73 protected:
74   /// Objects are created for features automatically
75   ModelAPI_Data()
76   {}
77 };
78
79 typedef boost::shared_ptr<ModelAPI_Data> DataPtr;
80
81
82 #endif