b311480e |
1 | // Created on: 1997-07-31 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 1997-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 | |
bc73b006 |
17 | #include <TDataStd_Name.hxx> |
42cf5bc1 |
18 | #include <TDF_Label.hxx> |
7fd59977 |
19 | |
c99ad5d7 |
20 | IMPLEMENT_DERIVED_ATTRIBUTE(TDataStd_Name,TDataStd_GenericExtString) |
92efcf78 |
21 | |
7fd59977 |
22 | //======================================================================= |
23 | //function : GetID |
24 | //purpose : |
25 | //======================================================================= |
7fd59977 |
26 | const Standard_GUID& TDataStd_Name::GetID () |
27 | { |
28 | static Standard_GUID TDataStd_NameID("2a96b608-ec8b-11d0-bee7-080009dc3333"); |
29 | return TDataStd_NameID; |
30 | } |
31 | |
69f1a899 |
32 | //======================================================================= |
33 | //function : SetAttr |
34 | //purpose : Implements Set functionality |
35 | //======================================================================= |
36 | static Handle(TDataStd_Name) SetAttr(const TDF_Label& label, |
37 | const TCollection_ExtendedString& theString, |
38 | const Standard_GUID& theGuid) |
39 | { |
40 | Handle(TDataStd_Name) N; |
41 | if (!label.FindAttribute(theGuid, N)) { |
42 | N = new TDataStd_Name (); |
c99ad5d7 |
43 | N->SetID (theGuid); |
69f1a899 |
44 | label.AddAttribute(N); |
45 | } |
46 | N->Set (theString); |
47 | return N; |
48 | } |
49 | |
7fd59977 |
50 | //======================================================================= |
51 | //function : Set |
52 | //purpose : |
53 | //======================================================================= |
54 | Handle(TDataStd_Name) TDataStd_Name::Set |
55 | (const TDF_Label& label, |
56 | const TCollection_ExtendedString& theString) |
57 | { |
69f1a899 |
58 | return SetAttr(label, theString, GetID()); |
7fd59977 |
59 | } |
60 | |
61 | //======================================================================= |
fa53efef |
62 | //function : Set |
63 | //purpose : Set user defined attribute |
7fd59977 |
64 | //======================================================================= |
7fd59977 |
65 | |
69f1a899 |
66 | Handle(TDataStd_Name) TDataStd_Name::Set (const TDF_Label& label, |
67 | const Standard_GUID& theGuid, |
fa53efef |
68 | const TCollection_ExtendedString& theString) |
69 | { |
69f1a899 |
70 | return SetAttr(label, theString, theGuid); |
fa53efef |
71 | } |
c99ad5d7 |
72 | |
7fd59977 |
73 | //======================================================================= |
74 | //function : TDataStd_Name |
c99ad5d7 |
75 | //purpose : |
7fd59977 |
76 | //======================================================================= |
c99ad5d7 |
77 | TDataStd_Name::TDataStd_Name() |
78 | { |
79 | myID = GetID(); |
80 | } |
7fd59977 |
81 | |
82 | //======================================================================= |
83 | //function : Set |
84 | //purpose : |
85 | //======================================================================= |
86 | void TDataStd_Name::Set (const TCollection_ExtendedString& S) |
87 | { |
7fd59977 |
88 | if(myString == S) return; |
89 | |
90 | Backup(); |
91 | myString = S; |
7fd59977 |
92 | } |
93 | |
fa53efef |
94 | //======================================================================= |
95 | //function : SetID |
96 | //purpose : |
97 | //======================================================================= |
fa53efef |
98 | void TDataStd_Name::SetID( const Standard_GUID& theGuid) |
99 | { |
100 | if(myID == theGuid) return; |
101 | |
102 | Backup(); |
103 | myID = theGuid; |
104 | } |
105 | |
5a1271c8 |
106 | //======================================================================= |
107 | //function : SetID |
108 | //purpose : sets default ID |
109 | //======================================================================= |
c99ad5d7 |
110 | |
5a1271c8 |
111 | void TDataStd_Name::SetID() |
112 | { |
113 | Backup(); |
114 | myID = GetID(); |
115 | } |
116 | |
fa53efef |
117 | // TDF_Attribute methods |
7fd59977 |
118 | //======================================================================= |
119 | //function : Dump |
120 | //purpose : |
121 | //======================================================================= |
122 | |
123 | Standard_OStream& TDataStd_Name::Dump (Standard_OStream& anOS) const |
124 | { |
125 | TDF_Attribute::Dump(anOS); |
fa53efef |
126 | anOS << " Name=|"<<myString<<"|"; |
127 | Standard_Character sguid[Standard_GUID_SIZE_ALLOC]; |
128 | myID.ToCString(sguid); |
04232180 |
129 | anOS << sguid << std::endl; |
7fd59977 |
130 | return anOS; |
131 | } |