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