Salome HOME
A unit test for the issue #1799
[modules/shaper.git] / src / Model / Model_AttributeRefAttr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeRefAttr.h
4 // Created:     8 May 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_AttributeRefAttr_H_
8 #define Model_AttributeRefAttr_H_
9
10 #include "Model.h"
11 #include "ModelAPI_AttributeRefAttr.h"
12 #include <TDF_Label.hxx>
13 #include <TDF_Reference.hxx>
14 #include <TDataStd_Comment.hxx>
15
16 /**\class Model_AttributeRefAttr
17  * \ingroup DataModel
18  * \brief Attribute that contains reference to an attribute of a feature 
19  * (located in the same document).
20  */
21
22 class Model_AttributeRefAttr : public ModelAPI_AttributeRefAttr
23 {
24   Handle_TDF_Reference myRef;  ///< reference to the feature label
25   TDF_Label myLab; ///< the main label of this attribute
26   ///< ID of the referenced attribute (empty if this is a reference to a feature)
27   Handle_TDataStd_Comment myID;
28  public:
29   /// Returns true if this attribute references to a object (not to the attribute)
30   MODEL_EXPORT virtual bool isObject();
31
32   /// Defines the reference to the attribute
33   MODEL_EXPORT virtual void setAttr(std::shared_ptr<ModelAPI_Attribute> theAttr);
34
35   /// Returns attribute referenced from this attribute
36   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Attribute> attr();
37
38   /// Defines the reference to the object
39   MODEL_EXPORT virtual void setObject(ObjectPtr theFeature);
40
41   /// Returns object referenced from this attribute
42   MODEL_EXPORT virtual ObjectPtr object();
43
44   /// Returns true if attribute was  initialized by some value
45   MODEL_EXPORT virtual bool isInitialized();
46
47  protected:
48   /// Objects are created for features automatically
49   MODEL_EXPORT Model_AttributeRefAttr(TDF_Label& theLabel);
50   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
51   virtual void reinit();
52
53   friend class Model_Data;
54 };
55
56 #endif