Salome HOME
Initial version
[modules/hydro.git] / src / HYDROData / HYDROData_Object.h
1 #ifndef HYDROData_Object_HeaderFile
2 #define HYDROData_Object_HeaderFile
3
4 #include <HYDROData.h>
5
6 #include <TDF_Label.hxx>
7 #include <QString>
8
9 ///! Kind of an object in a document
10 typedef int ObjectKind;
11 ///! Unrecognized object
12 const ObjectKind KIND_UNKNOWN = 0;
13 const ObjectKind KIND_IMAGE = 1;
14
15 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
16
17 /**\class HYDROData_Object
18  * \brief Generic class of any object in the data model.
19  *
20  * Interface for getting access to the object that belong to the data model.
21  * Managed by Document. Provides access to the common properties: 
22  * kind of an object, name.
23  */
24 class HYDROData_Object : public MMgt_TShared
25 {
26 public:
27   DEFINE_STANDARD_RTTI(HYDROData_Object);
28
29   /**
30    * Returns the kind of this object. Must be redefined in all objects of known type.
31    */
32   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
33
34   /**
35    * Returns the name of this object.
36    */
37   HYDRODATA_EXPORT QString GetName() const;
38
39   /**
40    * Updates the name of this object.
41    */
42   HYDRODATA_EXPORT void SetName(const QString& theName);
43
44   /**
45    * Checks is object exists in the data structure.
46    * \returns true is object is not exists in the data model
47    */
48   HYDRODATA_EXPORT bool IsRemoved() const;
49
50   /**
51    * Removes object from the data structure.
52    */
53   HYDRODATA_EXPORT void Remove();
54
55   /**
56    * Returns unique integer identifier of the object (may be used for ordering of objects)
57    */
58   HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
59
60   /**
61    * Copies all properties of this to the destinated object.
62    * Objects must be the same type.
63    * \param theDestination initialized object (from any document) - target of copying
64    */
65   HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
66
67 protected:
68
69   friend class HYDROData_Iterator;
70
71   /**
72    * Creates new object in the internal data structure. Use higher level objects 
73    * to create objects with real content.
74    */
75   HYDRODATA_EXPORT HYDROData_Object();
76
77   /**
78    * Destructs properties of the object and object itself, removes it from the document.
79    */
80   virtual HYDRODATA_EXPORT ~HYDROData_Object();
81
82   /**
83    * Put the object to the label of the document.
84    * \param theLabel new label of the object
85    */
86   HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
87
88   /**
89    * Returns the label of this object.
90    */
91   TDF_Label& Label() {return myLab;}
92
93 protected:
94   /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
95   TDF_Label myLab; ///< label of this object
96 };
97
98 ///! Is Equal for HYDROData_Object mapping
99 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);
100
101 #endif