0023024: Update headers of OCCT files
[occt.git] / src / TDataStd / TDataStd_Integer.cxx
CommitLineData
b311480e 1// Created on: 1997-03-06
2// Created by: Denis PASCAL
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <TDataStd_Integer.ixx>
24#include <TDF_Reference.hxx>
25
26//=======================================================================
27//function : GetID
28//purpose :
29//=======================================================================
30
31const Standard_GUID& TDataStd_Integer::GetID()
32{
33 static Standard_GUID TDataStd_IntegerID ("2a96b606-ec8b-11d0-bee7-080009dc3333");
34 return TDataStd_IntegerID;
35}
36
37
38//=======================================================================
39//function : Set
40//purpose :
41//=======================================================================
42
43Handle(TDataStd_Integer) TDataStd_Integer::Set (const TDF_Label& L,
44 const Standard_Integer V)
45
46{
47 Handle(TDataStd_Integer) A;
48 if (!L.FindAttribute (TDataStd_Integer::GetID(), A)) {
49 A = new TDataStd_Integer ();
50 L.AddAttribute(A);
51 }
52 A->Set (V);
53 return A;
54}
55
56//=======================================================================
57//function : TDataStd_Integer
58//purpose : Empty Constructor
59//=======================================================================
60
61TDataStd_Integer::TDataStd_Integer ()
62 : myValue (-1)
63 { }
64
65
66//=======================================================================
67//function : Set
68//purpose :
69//=======================================================================
70
71void TDataStd_Integer::Set(const Standard_Integer v)
72{
73 // OCC2932 correction
74 if(myValue == v) return;
75
76 Backup();
77 myValue = v;
78}
79
80
81//=======================================================================
82//function : Get
83//purpose :
84//=======================================================================
85
86Standard_Integer TDataStd_Integer::Get () const { return myValue; }
87
88
89//=======================================================================
90//function : IsCaptured
91//purpose :
92//=======================================================================
93
94Standard_Boolean TDataStd_Integer::IsCaptured() const
95{
96 Handle(TDF_Reference) R;
97 return (Label().FindAttribute(TDF_Reference::GetID(),R));
98}
99
100//=======================================================================
101//function : ID
102//purpose :
103//=======================================================================
104
105const Standard_GUID& TDataStd_Integer::ID () const { return GetID(); }
106
107
108//=======================================================================
109//function : NewEmpty
110//purpose :
111//=======================================================================
112
113Handle(TDF_Attribute) TDataStd_Integer::NewEmpty () const
114{
115 return new TDataStd_Integer ();
116}
117
118//=======================================================================
119//function : Restore
120//purpose :
121//=======================================================================
122
123void TDataStd_Integer::Restore(const Handle(TDF_Attribute)& With)
124{
125 myValue = Handle(TDataStd_Integer)::DownCast (With)->Get();
126}
127
128//=======================================================================
129//function : Paste
130//purpose :
131//=======================================================================
132
133void TDataStd_Integer::Paste (const Handle(TDF_Attribute)& Into,
134 const Handle(TDF_RelocationTable)& RT) const
135{
136 Handle(TDataStd_Integer)::DownCast(Into)->Set(myValue);
137}
138
139//=======================================================================
140//function : Dump
141//purpose :
142//=======================================================================
143
144Standard_OStream& TDataStd_Integer::Dump (Standard_OStream& anOS) const
145{
146 anOS << "Integer:: "<< this <<" : ";
147 anOS << myValue;
148//
149 anOS <<"\nAttribute fields: ";
150 anOS << TDF_Attribute::Dump(anOS);
151 return anOS;
152}
153