Salome HOME
Added the system of reinitialization of attributes instead of re-creation of them...
[modules/shaper.git] / src / Model / Model_AttributeReference.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeReference.h
4 // Created:     8 May 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_AttributeReference_H_
8 #define Model_AttributeReference_H_
9
10 #include "Model.h"
11 #include "ModelAPI_AttributeReference.h"
12 #include <ModelAPI_Feature.h>
13 #include <TDF_Label.hxx>
14 #include <TDF_Reference.hxx>
15
16 /**\class Model_AttributeReference
17  * \ingroup DataModel
18  * \brief Attribute that contains reference to feature (located in the same document).
19  */
20
21 class Model_AttributeReference : public ModelAPI_AttributeReference
22 {
23   TDF_Label myLab; ///< the main label of this attribute
24   Handle_TDF_Reference myRef;  ///< references to the feature label
25  public:
26   /// Defines the object referenced from this attribute
27   MODEL_EXPORT virtual void setValue(ObjectPtr theObject);
28
29   /// Returns object referenced from this attribute
30   MODEL_EXPORT virtual ObjectPtr value();
31
32   MODEL_EXPORT ~Model_AttributeReference();
33
34   MODEL_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
35
36   /// Returns true if attribute was  initialized by some value
37   MODEL_EXPORT virtual bool isInitialized();
38
39
40 protected:
41   /// Objects are created for features automatically
42   MODEL_EXPORT Model_AttributeReference(TDF_Label& theLabel);
43   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
44   virtual void reinit();
45
46   friend class Model_Data;
47   friend class Model_AttributeSelection;
48 };
49
50 #endif