0023024: Update headers of OCCT files
[occt.git] / src / TDataStd / TDataStd_BooleanList.cxx
1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21 #include <TDataStd_BooleanList.ixx>
22 #include <TDataStd_ListIteratorOfListOfByte.hxx>
23
24 //=======================================================================
25 //function : GetID
26 //purpose  : 
27 //=======================================================================
28 const Standard_GUID& TDataStd_BooleanList::GetID() 
29
30   static Standard_GUID TDataStd_BooleanListID ("23A9D60E-A033-44d8-96EE-015587A41BBC");
31   return TDataStd_BooleanListID; 
32 }
33
34 //=======================================================================
35 //function : TDataStd_BooleanList
36 //purpose  : Empty Constructor
37 //=======================================================================
38 TDataStd_BooleanList::TDataStd_BooleanList() 
39 {
40
41 }
42
43 //=======================================================================
44 //function : Set
45 //purpose  : 
46 //=======================================================================
47 Handle(TDataStd_BooleanList) TDataStd_BooleanList::Set(const TDF_Label& label) 
48 {
49   Handle(TDataStd_BooleanList) A;
50   if (!label.FindAttribute (TDataStd_BooleanList::GetID(), A)) 
51   {
52     A = new TDataStd_BooleanList;
53     label.AddAttribute(A);
54   }
55   return A;
56 }
57
58 //=======================================================================
59 //function : IsEmpty
60 //purpose  : 
61 //=======================================================================
62 Standard_Boolean TDataStd_BooleanList::IsEmpty() const
63 {
64   return myList.IsEmpty();
65 }
66
67 //=======================================================================
68 //function : Extent
69 //purpose  : 
70 //=======================================================================
71 Standard_Integer TDataStd_BooleanList::Extent() const
72 {
73   return myList.Extent();
74 }
75
76 //=======================================================================
77 //function : Prepend
78 //purpose  : 
79 //=======================================================================
80 void TDataStd_BooleanList::Prepend(const Standard_Boolean value)
81 {
82   Backup();
83   myList.Prepend( value ? 1 : 0 );
84 }
85
86 //=======================================================================
87 //function : Append
88 //purpose  : 
89 //=======================================================================
90 void TDataStd_BooleanList::Append(const Standard_Boolean value)
91 {
92   Backup();
93   myList.Append( value ? 1 : 0 );
94 }
95
96 //=======================================================================
97 //function : Clear
98 //purpose  : 
99 //=======================================================================
100 void TDataStd_BooleanList::Clear()
101 {
102   Backup();
103   myList.Clear();
104 }
105
106 //=======================================================================
107 //function : First
108 //purpose  : 
109 //=======================================================================
110 Standard_Boolean TDataStd_BooleanList::First() const
111 {
112   return myList.First() == 1;
113 }
114
115 //=======================================================================
116 //function : Last
117 //purpose  : 
118 //=======================================================================
119 Standard_Boolean TDataStd_BooleanList::Last() const
120 {
121   return myList.Last() == 1;
122 }
123
124 //=======================================================================
125 //function : List
126 //purpose  : 
127 //=======================================================================
128 const TDataStd_ListOfByte& TDataStd_BooleanList::List() const
129 {
130   return myList;
131 }
132
133 //=======================================================================
134 //function : ID
135 //purpose  : 
136 //=======================================================================
137 const Standard_GUID& TDataStd_BooleanList::ID () const 
138
139   return GetID(); 
140 }
141
142 //=======================================================================
143 //function : NewEmpty
144 //purpose  : 
145 //=======================================================================
146 Handle(TDF_Attribute) TDataStd_BooleanList::NewEmpty () const
147 {  
148   return new TDataStd_BooleanList(); 
149 }
150
151 //=======================================================================
152 //function : Restore
153 //purpose  : 
154 //=======================================================================
155 void TDataStd_BooleanList::Restore(const Handle(TDF_Attribute)& With) 
156 {
157   myList.Clear();
158   Handle(TDataStd_BooleanList) aList = Handle(TDataStd_BooleanList)::DownCast(With);
159   TDataStd_ListIteratorOfListOfByte itr(aList->List());
160   for (; itr.More(); itr.Next())
161   {
162     myList.Append(itr.Value());
163   }
164 }
165
166 //=======================================================================
167 //function : Paste
168 //purpose  : 
169 //=======================================================================
170 void TDataStd_BooleanList::Paste (const Handle(TDF_Attribute)& Into,
171                                   const Handle(TDF_RelocationTable)& ) const
172 {
173   Handle(TDataStd_BooleanList) aList = Handle(TDataStd_BooleanList)::DownCast(Into);
174   aList->Clear();
175   TDataStd_ListIteratorOfListOfByte itr(myList);
176   for (; itr.More(); itr.Next())
177   {
178     aList->Append(itr.Value());
179   }
180 }
181
182 //=======================================================================
183 //function : Dump
184 //purpose  : 
185 //=======================================================================
186 Standard_OStream& TDataStd_BooleanList::Dump (Standard_OStream& anOS) const
187 {  
188   anOS << "BooleanList";
189   return anOS;
190 }