1 #ifndef HYDROData_Object_HeaderFile
2 #define HYDROData_Object_HeaderFile
6 #include <NCollection_Sequence.hxx>
7 #include <TDF_Label.hxx>
10 ///! Kind of an object in a document
11 typedef int ObjectKind;
12 ///! Unrecognized object
13 const ObjectKind KIND_UNKNOWN = 0;
14 const ObjectKind KIND_IMAGE = 1;
16 DEFINE_STANDARD_HANDLE(HYDROData_Object, MMgt_TShared)
18 /**\class HYDROData_Object
19 * \brief Generic class of any object in the data model.
21 * Interface for getting access to the object that belong to the data model.
22 * Managed by Document. Provides access to the common properties:
23 * kind of an object, name.
25 class HYDROData_Object : public MMgt_TShared
28 DEFINE_STANDARD_RTTI(HYDROData_Object);
31 * Returns the kind of this object. Must be redefined in all objects of known type.
33 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_UNKNOWN;}
36 * Returns the name of this object.
38 HYDRODATA_EXPORT QString GetName() const;
41 * Updates the name of this object.
43 HYDRODATA_EXPORT void SetName(const QString& theName);
46 * Checks is object exists in the data structure.
47 * \returns true is object is not exists in the data model
49 HYDRODATA_EXPORT bool IsRemoved() const;
52 * Removes object from the data structure.
54 HYDRODATA_EXPORT void Remove();
57 * Returns unique integer identifier of the object (may be used for ordering of objects)
59 HYDRODATA_EXPORT inline int ID() const {return myLab.Tag();}
62 * Copies all properties of this to the destinated object.
63 * Objects must be the same type.
64 * \param theDestination initialized object (from any document) - target of copying
66 HYDRODATA_EXPORT void CopyTo(Handle_HYDROData_Object theDestination) const;
69 * Returns the label of this object.
71 HYDRODATA_EXPORT TDF_Label& Label() {return myLab;}
75 friend class HYDROData_Iterator;
78 * Creates new object in the internal data structure. Use higher level objects
79 * to create objects with real content.
81 HYDRODATA_EXPORT HYDROData_Object();
84 * Destructs properties of the object and object itself, removes it from the document.
86 virtual HYDRODATA_EXPORT ~HYDROData_Object();
89 * Put the object to the label of the document.
90 * \param theLabel new label of the object
92 HYDRODATA_EXPORT virtual void SetLabel(TDF_Label theLabel);
95 * Internal method that used to store the byte array attribute
96 * \param theTag tag of a label to store attribute (for 0 this is myLab)
97 * \param theData pointer to bytes array
98 * \param theLen number of bytes in byte array that must be stored
100 void SaveByteArray(const int theTag, const char* theData, const int theLen);
103 * Internal method that used to retreive the content of byte array attribute
104 * \param theTag tag of a label that keeps the attribute (for 0 this is myLab)
105 * \param theLen number of bytes in byte array
106 * \returns pointer to the internal data structure wit harray content,
107 * or NULL if array size is zero
109 const char* ByteArray(const int theTag, int& theLen);
112 /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty.
113 TDF_Label myLab; ///< label of this object
116 typedef NCollection_Sequence<Handle_HYDROData_Object> HYDROData_SequenceOfObjects;
118 ///! Is Equal for HYDROData_Object mapping
119 HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Object& theObj1, const Handle_HYDROData_Object& theObj2);