]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.cxx
Salome HOME
41fcd0c8f29ad607b897a3dedd4f8b86b4876db6
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeUserID.cxx
1 //  File   : SALOMEDSImpl_AttributeUAttribute.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5
6 #include "SALOMEDSImpl_AttributeUserID.hxx"
7
8 using namespace std;
9
10 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeUserID, SALOMEDSImpl_GenericAttribute )
11 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeUserID, SALOMEDSImpl_GenericAttribute )
12
13 Handle(SALOMEDSImpl_AttributeUserID) SALOMEDSImpl_AttributeUserID::Set (const TDF_Label& L, const Standard_GUID& ID) 
14 {
15   Handle(SALOMEDSImpl_AttributeUserID) A;
16   if (!L.FindAttribute(ID, A)) {
17     A = new  SALOMEDSImpl_AttributeUserID(); 
18     A->SetValue(ID);
19     L.AddAttribute(A);
20   }
21   return A;
22 }
23
24 //=======================================================================
25 //function : ID
26 //purpose  :
27 //=======================================================================
28 const Standard_GUID& SALOMEDSImpl_AttributeUserID::ID() const
29 { return myID; }
30
31
32 //=======================================================================
33 //function : SetValue
34 //purpose  :
35 //=======================================================================
36 void SALOMEDSImpl_AttributeUserID::SetValue( const Standard_GUID&  guid)
37 {
38   CheckLocked();
39   if(myID == guid) return;
40
41   Backup();
42   myID = guid;
43   
44   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
45 }        
46
47 //=======================================================================
48 //function : NewEmpty
49 //purpose  :
50 //=======================================================================
51 Handle(TDF_Attribute) SALOMEDSImpl_AttributeUserID::NewEmpty () const
52 {
53   Handle(SALOMEDSImpl_AttributeUserID) A = new SALOMEDSImpl_AttributeUserID();
54   A->SetValue(myID);
55   return A;
56 }
57
58 //=======================================================================
59 //function : Restore
60 //purpose  :
61 //=======================================================================
62 void SALOMEDSImpl_AttributeUserID::Restore(const Handle(TDF_Attribute)& with)
63 {
64   Handle(SALOMEDSImpl_AttributeUserID) A = Handle(SALOMEDSImpl_AttributeUserID)::DownCast(with);
65   SetValue( A->ID() );
66 }
67
68 //=======================================================================
69 //function : Paste
70 //purpose  :
71 //=======================================================================
72 void SALOMEDSImpl_AttributeUserID::Paste (const Handle(TDF_Attribute)& into,
73                                           const Handle(TDF_RelocationTable)& RT) const
74 {
75   Handle(SALOMEDSImpl_AttributeUserID) A = Handle(SALOMEDSImpl_AttributeUserID)::DownCast(into);
76   A->SetValue( myID );
77 }    
78
79 TCollection_AsciiString SALOMEDSImpl_AttributeUserID::Type() 
80 {
81
82   char* aUAttrName = new char[60];
83   char aGUID[40];
84   ID().ToCString(aGUID);
85   sprintf(aUAttrName, "AttributeUserID_%s",aGUID);
86
87   TCollection_AsciiString ret(aUAttrName);
88   delete aUAttrName;
89
90   return ret;
91 }