0030773: Application Framework - To allow to inherit existing attributes to reuse...
[occt.git] / src / TDataStd / TDataStd_GenericExtString.cxx
1 // Copyright (c) 2020 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <TDataStd_GenericExtString.hxx>
15 #include <Standard_Dump.hxx>
16
17 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_GenericExtString,TDF_Attribute)
18
19 //=======================================================================
20 //function : Set
21 //purpose  : 
22 //=======================================================================
23 void TDataStd_GenericExtString::Set (const TCollection_ExtendedString& S) 
24 {
25   if(myString == S) return;
26  
27   Backup();
28   myString = S;
29 }
30
31 //=======================================================================
32 //function : Get
33 //purpose  : 
34 //=======================================================================
35 const TCollection_ExtendedString& TDataStd_GenericExtString::Get () const
36 {
37   return myString;
38 }
39
40 //=======================================================================
41 //function : SetID
42 //purpose  :
43 //=======================================================================
44 void TDataStd_GenericExtString::SetID( const Standard_GUID&  theGuid)
45 {  
46   if(myID == theGuid) return;
47
48   Backup();
49   myID = theGuid;
50 }
51
52 //=======================================================================
53 //function : ID
54 //purpose  : 
55 //=======================================================================
56 const Standard_GUID& TDataStd_GenericExtString::ID () const { return myID; }
57
58 //=======================================================================
59 //function : Restore
60 //purpose  : 
61 //=======================================================================
62 void TDataStd_GenericExtString::Restore(const Handle(TDF_Attribute)& with) 
63 {
64    Handle(TDataStd_GenericExtString) anAtt = Handle(TDataStd_GenericExtString)::DownCast (with);
65    myString = anAtt->Get();
66    myID = anAtt->ID();
67 }
68
69 //=======================================================================
70 //function : Paste
71 //purpose  : 
72 //=======================================================================
73 void TDataStd_GenericExtString::Paste (const Handle(TDF_Attribute)& into,
74                                        const Handle(TDF_RelocationTable)&/* RT*/) const
75 {
76   Handle(TDataStd_GenericExtString) anAtt = Handle(TDataStd_GenericExtString)::DownCast (into);
77   anAtt->Set(myString);
78   anAtt->SetID(myID);
79 }
80
81 //=======================================================================
82 //function : DumpJson
83 //purpose  : 
84 //=======================================================================
85 void TDataStd_GenericExtString::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
86 {
87   OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
88   OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
89   OCCT_DUMP_FIELD_VALUE_STRING (theOStream, Get())
90   OCCT_DUMP_FIELD_VALUE_GUID (theOStream, myID)
91 }