]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.cxx
Salome HOME
PR: merge from branch BR_UnitTests tag mergeto_trunk_17oct05
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeReference.cxx
1 //  File   : SALOMEDSImpl_AttributeReference.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5 #include "SALOMEDSImpl_AttributeReference.hxx"
6 #include <TDF_Tool.hxx>
7 #include <TDF_Data.hxx>
8 #include <TDF_RelocationTable.hxx>
9
10 using namespace std;
11
12 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeReference, SALOMEDSImpl_GenericAttribute )
13 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeReference, SALOMEDSImpl_GenericAttribute )
14
15
16 //=======================================================================
17 //function : GetID
18 //purpose  :
19 //=======================================================================
20 const Standard_GUID& SALOMEDSImpl_AttributeReference::GetID ()
21 {
22   static Standard_GUID refID ("D913E0B3-0A9F-4ea6-9480-18A9B72D9D86");
23   return refID;
24
25
26 Handle(SALOMEDSImpl_AttributeReference) SALOMEDSImpl_AttributeReference::Set(const TDF_Label& theLabel, 
27                                                                              const TDF_Label& theRefLabel)
28 {
29   Handle(SALOMEDSImpl_AttributeReference) A;
30   if (!theLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), A)) {
31     A = new  SALOMEDSImpl_AttributeReference(); 
32     theLabel.AddAttribute(A);
33   }
34
35   A->Set(theRefLabel);  
36   return A;  
37 }
38
39 //=======================================================================
40 //function : Set
41 //purpose  :
42 //=======================================================================
43 void SALOMEDSImpl_AttributeReference::Set(const TDF_Label& Origin)
44 {
45   CheckLocked();
46
47   if(myLabel == Origin) return;
48
49   Backup();
50   myLabel = Origin;
51
52   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
53 }  
54
55 //=======================================================================
56 //function : ID
57 //purpose  :
58 //=======================================================================
59 const Standard_GUID& SALOMEDSImpl_AttributeReference::ID () const { return GetID(); } 
60
61
62 TCollection_AsciiString SALOMEDSImpl_AttributeReference::Save() 
63 {
64   TCollection_AsciiString anEntry;
65   TDF_Tool::Entry(myLabel, anEntry);
66   return anEntry;
67 }
68
69 void SALOMEDSImpl_AttributeReference::Load(const TCollection_AsciiString& value) 
70 {
71   TDF_Label aLabel;
72   TDF_Tool::Label(Label().Data(), value, aLabel);
73   myLabel = aLabel;
74 }
75
76 //=======================================================================
77 //function : NewEmpty
78 //purpose  : 
79 //=======================================================================
80 Handle(TDF_Attribute) SALOMEDSImpl_AttributeReference::NewEmpty () const
81 {  
82   return new SALOMEDSImpl_AttributeReference(); 
83 }
84
85 //=======================================================================
86 //function : Restore
87 //purpose  :
88 //=======================================================================
89
90 void SALOMEDSImpl_AttributeReference::Restore(const Handle(TDF_Attribute)& With)
91 {
92   myLabel = Handle(SALOMEDSImpl_AttributeReference)::DownCast (With)->Get ();
93 }
94
95 //=======================================================================
96 //function : Paste
97 //purpose  :
98 //=======================================================================
99
100 void SALOMEDSImpl_AttributeReference::Paste (const Handle(TDF_Attribute)& Into,
101                                              const Handle(TDF_RelocationTable)& RT) const
102 {
103   TDF_Label tLab;
104   if (!myLabel.IsNull()) {
105     if (!RT->HasRelocation(myLabel,tLab)) tLab = myLabel;
106   }
107   Handle(SALOMEDSImpl_AttributeReference)::DownCast(Into)->Set(tLab);
108