b311480e |
1 | // Created on: 1998-01-15 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Standard_GUID.hxx> |
19 | #include <Standard_Type.hxx> |
7fd59977 |
20 | #include <TCollection_AsciiString.hxx> |
42cf5bc1 |
21 | #include <TCollection_ExtendedString.hxx> |
22 | #include <TDataStd_Comment.hxx> |
23 | #include <TDataStd_Integer.hxx> |
24 | #include <TDataStd_Real.hxx> |
25 | #include <TDF_Attribute.hxx> |
7fd59977 |
26 | #include <TDF_ChildIDIterator.hxx> |
27 | #include <TDF_ChildIterator.hxx> |
28 | #include <TDF_Label.hxx> |
42cf5bc1 |
29 | #include <TDF_RelocationTable.hxx> |
7fd59977 |
30 | #include <TDF_Tool.hxx> |
7fd59977 |
31 | |
32 | #define lid1 45 |
33 | #define lid2 36 |
34 | |
35 | //======================================================================= |
36 | //function : GetID |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | const Standard_GUID& TDataStd_Comment::GetID () |
41 | { |
42 | static Standard_GUID TDataStd_CommentID ("2a96b616-ec8b-11d0-bee7-080009dc3333"); |
43 | return TDataStd_CommentID; |
44 | } |
45 | |
46 | |
47 | |
48 | //======================================================================= |
49 | //function : Set |
50 | //purpose : |
51 | //======================================================================= |
52 | |
53 | Handle(TDataStd_Comment) TDataStd_Comment::Set (const TDF_Label& L, |
54 | const TCollection_ExtendedString& S) |
55 | { |
56 | Handle(TDataStd_Comment) A; |
57 | if (!L.FindAttribute(TDataStd_Comment::GetID(),A)) { |
58 | A = new TDataStd_Comment (); |
59 | L.AddAttribute(A); |
60 | } |
61 | A->Set (S); |
62 | return A; |
63 | } |
64 | |
65 | |
66 | //======================================================================= |
67 | //function : Set |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | Handle(TDataStd_Comment) TDataStd_Comment::Set (const TDF_Label& L) |
72 | { |
73 | Handle(TDataStd_Comment) A; |
74 | if (!L.FindAttribute(TDataStd_Comment::GetID(),A)) { |
75 | A = new TDataStd_Comment (); |
76 | L.AddAttribute(A); |
77 | } |
78 | return A; |
79 | } |
80 | |
81 | |
82 | //======================================================================= |
83 | //function : TDataStd_Comment |
84 | //purpose : |
85 | //======================================================================= |
86 | TDataStd_Comment::TDataStd_Comment () { } |
87 | |
88 | |
89 | |
90 | //======================================================================= |
91 | //function : Set |
92 | //purpose : |
93 | //======================================================================= |
94 | void TDataStd_Comment::Set (const TCollection_ExtendedString& S) |
95 | { |
96 | // OCC2932 correction |
97 | if(myString == S) return; |
98 | |
99 | Backup(); |
100 | |
101 | myString = S; |
102 | } |
103 | |
104 | |
105 | |
106 | //======================================================================= |
107 | //function : Get |
108 | //purpose : |
109 | //======================================================================= |
110 | const TCollection_ExtendedString& TDataStd_Comment::Get () const |
111 | { |
112 | return myString; |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : ID |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | const Standard_GUID& TDataStd_Comment::ID () const { return GetID(); } |
121 | |
122 | |
123 | //======================================================================= |
124 | //function : NewEmpty |
125 | //purpose : |
126 | //======================================================================= |
127 | |
128 | Handle(TDF_Attribute) TDataStd_Comment::NewEmpty () const |
129 | { |
130 | return new TDataStd_Comment(); |
131 | } |
132 | |
133 | //======================================================================= |
134 | //function : Restore |
135 | //purpose : |
136 | //======================================================================= |
137 | |
138 | void TDataStd_Comment::Restore(const Handle(TDF_Attribute)& with) |
139 | { |
140 | myString = Handle(TDataStd_Comment)::DownCast (with)->Get (); |
141 | return; |
142 | } |
143 | |
144 | //======================================================================= |
145 | //function : Paste |
146 | //purpose : |
147 | //======================================================================= |
148 | |
149 | void TDataStd_Comment::Paste (const Handle(TDF_Attribute)& into, |
150 | const Handle(TDF_RelocationTable)& /*RT*/) const |
151 | { |
152 | Handle(TDataStd_Comment)::DownCast (into)->Set (myString); |
153 | } |
154 | |
155 | //======================================================================= |
156 | //function : Dump |
157 | //purpose : |
158 | //======================================================================= |
159 | |
160 | Standard_OStream& TDataStd_Comment::Dump (Standard_OStream& anOS) const |
161 | { |
162 | TDF_Attribute::Dump(anOS); |
163 | anOS << "Comment=|"<<myString<<"|"; |
164 | return anOS; |
165 | } |
166 | Standard_Boolean TDataStd_Comment:: |
167 | AfterRetrieval(const Standard_Boolean) |
168 | { |
169 | return Standard_True; |
170 | } |