Salome HOME
Added a method Modify to Study and a method SetModifyFlag to GenericAttribute. Now...
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributePersistentRef.cxx
1 //  File   : SALOMEDSImpl_AttributePersistentRef.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5
6 #include "SALOMEDSImpl_AttributePersistentRef.hxx"
7 #include <Standard_GUID.hxx>
8
9 using namespace std;
10
11 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributePersistentRef, SALOMEDSImpl_GenericAttribute )
12 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributePersistentRef, SALOMEDSImpl_GenericAttribute )
13
14 //=======================================================================
15 //function : GetID
16 //purpose  : 
17 //=======================================================================
18
19 const Standard_GUID& SALOMEDSImpl_AttributePersistentRef::GetID () 
20 {
21   static Standard_GUID SALOMEDSImpl_AttributePersistentRefID ("92888E06-7074-11d5-A690-0800369C8A03");
22   return SALOMEDSImpl_AttributePersistentRefID;
23 }
24
25
26
27 //=======================================================================
28 //function : Set
29 //purpose  : 
30 //=======================================================================
31
32 Handle(SALOMEDSImpl_AttributePersistentRef) SALOMEDSImpl_AttributePersistentRef::Set (const TDF_Label& L,
33                                                                                       const TCollection_ExtendedString& S)
34 {
35   Handle(SALOMEDSImpl_AttributePersistentRef) A;
36   if (!L.FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID(),A)) {
37     A = new  SALOMEDSImpl_AttributePersistentRef(); 
38     L.AddAttribute(A);
39   }
40   
41   A->SetValue (S); 
42   return A;
43 }
44
45
46 //=======================================================================
47 //function : constructor
48 //purpose  : 
49 //=======================================================================
50 SALOMEDSImpl_AttributePersistentRef::SALOMEDSImpl_AttributePersistentRef()
51 :SALOMEDSImpl_GenericAttribute("AttributePersistentRef")
52 {
53 }
54
55 //=======================================================================
56 //function : ID
57 //purpose  : 
58 //=======================================================================
59
60 const Standard_GUID& SALOMEDSImpl_AttributePersistentRef::ID () const { return GetID(); }
61
62
63 //=======================================================================
64 //function : SetValue
65 //purpose  :
66 //=======================================================================
67 void SALOMEDSImpl_AttributePersistentRef::SetValue (const TCollection_ExtendedString& S)
68 {
69   CheckLocked();
70
71   if(myString == S) return;
72
73   Backup();
74
75   myString = S;
76   
77   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
78 }
79
80 //=======================================================================
81 //function : NewEmpty
82 //purpose  : 
83 //=======================================================================
84
85 Handle(TDF_Attribute) SALOMEDSImpl_AttributePersistentRef::NewEmpty () const
86 {  
87   return new SALOMEDSImpl_AttributePersistentRef(); 
88 }
89
90 //=======================================================================
91 //function : Restore
92 //purpose  : 
93 //=======================================================================
94
95 void SALOMEDSImpl_AttributePersistentRef::Restore(const Handle(TDF_Attribute)& with) 
96 {
97   myString = Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast (with)->Value ();
98 }
99
100 //=======================================================================
101 //function : Paste
102 //purpose  : 
103 //=======================================================================
104
105 void SALOMEDSImpl_AttributePersistentRef::Paste (const Handle(TDF_Attribute)& into,
106                                                  const Handle(TDF_RelocationTable)& RT) const
107 {
108   Handle(SALOMEDSImpl_AttributePersistentRef)::DownCast (into)->SetValue(myString);
109 }
110