b311480e |
1 | // Created on: 1997-03-06 |
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 | |
17 | #include <TDataStd_Integer.ixx> |
18 | #include <TDF_Reference.hxx> |
19 | |
20 | //======================================================================= |
21 | //function : GetID |
22 | //purpose : |
23 | //======================================================================= |
24 | |
25 | const Standard_GUID& TDataStd_Integer::GetID() |
26 | { |
27 | static Standard_GUID TDataStd_IntegerID ("2a96b606-ec8b-11d0-bee7-080009dc3333"); |
28 | return TDataStd_IntegerID; |
29 | } |
30 | |
31 | |
32 | //======================================================================= |
33 | //function : Set |
34 | //purpose : |
35 | //======================================================================= |
36 | |
37 | Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L, |
38 | const Standard_Integer V) |
39 | |
40 | { |
41 | Handle(TDataStd_Integer) A; |
42 | if (!L.FindAttribute (TDataStd_Integer::GetID(), A)) { |
43 | A = new TDataStd_Integer (); |
44 | L.AddAttribute(A); |
45 | } |
46 | A->Set (V); |
47 | return A; |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : TDataStd_Integer |
52 | //purpose : Empty Constructor |
53 | //======================================================================= |
54 | |
55 | TDataStd_Integer::TDataStd_Integer () |
56 | : myValue (-1) |
57 | { } |
58 | |
59 | |
60 | //======================================================================= |
61 | //function : Set |
62 | //purpose : |
63 | //======================================================================= |
64 | |
65 | void TDataStd_Integer::Set(const Standard_Integer v) |
66 | { |
67 | // OCC2932 correction |
68 | if(myValue == v) return; |
69 | |
70 | Backup(); |
71 | myValue = v; |
72 | } |
73 | |
74 | |
75 | //======================================================================= |
76 | //function : Get |
77 | //purpose : |
78 | //======================================================================= |
79 | |
80 | Standard_Integer TDataStd_Integer::Get () const { return myValue; } |
81 | |
82 | |
83 | //======================================================================= |
84 | //function : IsCaptured |
85 | //purpose : |
86 | //======================================================================= |
87 | |
88 | Standard_Boolean TDataStd_Integer::IsCaptured() const |
89 | { |
90 | Handle(TDF_Reference) R; |
91 | return (Label().FindAttribute(TDF_Reference::GetID(),R)); |
92 | } |
93 | |
94 | //======================================================================= |
95 | //function : ID |
96 | //purpose : |
97 | //======================================================================= |
98 | |
99 | const Standard_GUID& TDataStd_Integer::ID () const { return GetID(); } |
100 | |
101 | |
102 | //======================================================================= |
103 | //function : NewEmpty |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const |
108 | { |
109 | return new TDataStd_Integer (); |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : Restore |
114 | //purpose : |
115 | //======================================================================= |
116 | |
117 | void TDataStd_Integer::Restore(const Handle(TDF_Attribute)& With) |
118 | { |
119 | myValue = Handle(TDataStd_Integer)::DownCast (With)->Get(); |
120 | } |
121 | |
122 | //======================================================================= |
123 | //function : Paste |
124 | //purpose : |
125 | //======================================================================= |
126 | |
127 | void TDataStd_Integer::Paste (const Handle(TDF_Attribute)& Into, |
35e08fe8 |
128 | const Handle(TDF_RelocationTable)& /*RT*/) const |
7fd59977 |
129 | { |
130 | Handle(TDataStd_Integer)::DownCast(Into)->Set(myValue); |
131 | } |
132 | |
133 | //======================================================================= |
134 | //function : Dump |
135 | //purpose : |
136 | //======================================================================= |
137 | |
138 | Standard_OStream& TDataStd_Integer::Dump (Standard_OStream& anOS) const |
139 | { |
140 | anOS << "Integer:: "<< this <<" : "; |
141 | anOS << myValue; |
142 | // |
143 | anOS <<"\nAttribute fields: "; |
008aef40 |
144 | TDF_Attribute::Dump(anOS); |
7fd59977 |
145 | return anOS; |
146 | } |
147 | |