0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / TDataStd / TDataStd_BooleanList.cxx
1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <Standard_GUID.hxx>
18 #include <Standard_Type.hxx>
19 #include <TDataStd_BooleanList.hxx>
20 #include <TDataStd_ListIteratorOfListOfByte.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <TDF_Label.hxx>
23 #include <TDF_RelocationTable.hxx>
24
25 //=======================================================================
26 //function : GetID
27 //purpose  : 
28 //=======================================================================
29 const Standard_GUID& TDataStd_BooleanList::GetID() 
30
31   static Standard_GUID TDataStd_BooleanListID ("23A9D60E-A033-44d8-96EE-015587A41BBC");
32   return TDataStd_BooleanListID; 
33 }
34
35 //=======================================================================
36 //function : TDataStd_BooleanList
37 //purpose  : Empty Constructor
38 //=======================================================================
39 TDataStd_BooleanList::TDataStd_BooleanList() 
40 {
41
42 }
43
44 //=======================================================================
45 //function : Set
46 //purpose  : 
47 //=======================================================================
48 Handle(TDataStd_BooleanList) TDataStd_BooleanList::Set(const TDF_Label& label) 
49 {
50   Handle(TDataStd_BooleanList) A;
51   if (!label.FindAttribute (TDataStd_BooleanList::GetID(), A)) 
52   {
53     A = new TDataStd_BooleanList;
54     label.AddAttribute(A);
55   }
56   return A;
57 }
58
59 //=======================================================================
60 //function : IsEmpty
61 //purpose  : 
62 //=======================================================================
63 Standard_Boolean TDataStd_BooleanList::IsEmpty() const
64 {
65   return myList.IsEmpty();
66 }
67
68 //=======================================================================
69 //function : Extent
70 //purpose  : 
71 //=======================================================================
72 Standard_Integer TDataStd_BooleanList::Extent() const
73 {
74   return myList.Extent();
75 }
76
77 //=======================================================================
78 //function : Prepend
79 //purpose  : 
80 //=======================================================================
81 void TDataStd_BooleanList::Prepend(const Standard_Boolean value)
82 {
83   Backup();
84   myList.Prepend( value ? 1 : 0 );
85 }
86
87 //=======================================================================
88 //function : Append
89 //purpose  : 
90 //=======================================================================
91 void TDataStd_BooleanList::Append(const Standard_Boolean value)
92 {
93   Backup();
94   myList.Append( value ? 1 : 0 );
95 }
96
97 //=======================================================================
98 //function : Clear
99 //purpose  : 
100 //=======================================================================
101 void TDataStd_BooleanList::Clear()
102 {
103   Backup();
104   myList.Clear();
105 }
106
107 //=======================================================================
108 //function : First
109 //purpose  : 
110 //=======================================================================
111 Standard_Boolean TDataStd_BooleanList::First() const
112 {
113   return myList.First() == 1;
114 }
115
116 //=======================================================================
117 //function : Last
118 //purpose  : 
119 //=======================================================================
120 Standard_Boolean TDataStd_BooleanList::Last() const
121 {
122   return myList.Last() == 1;
123 }
124
125 //=======================================================================
126 //function : List
127 //purpose  : 
128 //=======================================================================
129 const TDataStd_ListOfByte& TDataStd_BooleanList::List() const
130 {
131   return myList;
132 }
133
134 //=======================================================================
135 //function : ID
136 //purpose  : 
137 //=======================================================================
138 const Standard_GUID& TDataStd_BooleanList::ID () const 
139
140   return GetID(); 
141 }
142
143 //=======================================================================
144 //function : NewEmpty
145 //purpose  : 
146 //=======================================================================
147 Handle(TDF_Attribute) TDataStd_BooleanList::NewEmpty () const
148 {  
149   return new TDataStd_BooleanList(); 
150 }
151
152 //=======================================================================
153 //function : Restore
154 //purpose  : 
155 //=======================================================================
156 void TDataStd_BooleanList::Restore(const Handle(TDF_Attribute)& With) 
157 {
158   myList.Clear();
159   Handle(TDataStd_BooleanList) aList = Handle(TDataStd_BooleanList)::DownCast(With);
160   TDataStd_ListIteratorOfListOfByte itr(aList->List());
161   for (; itr.More(); itr.Next())
162   {
163     myList.Append(itr.Value());
164   }
165 }
166
167 //=======================================================================
168 //function : Paste
169 //purpose  : 
170 //=======================================================================
171 void TDataStd_BooleanList::Paste (const Handle(TDF_Attribute)& Into,
172                                   const Handle(TDF_RelocationTable)& ) const
173 {
174   Handle(TDataStd_BooleanList) aList = Handle(TDataStd_BooleanList)::DownCast(Into);
175   aList->Clear();
176   TDataStd_ListIteratorOfListOfByte itr(myList);
177   for (; itr.More(); itr.Next())
178   {
179     aList->Append(itr.Value());
180   }
181 }
182
183 //=======================================================================
184 //function : Dump
185 //purpose  : 
186 //=======================================================================
187 Standard_OStream& TDataStd_BooleanList::Dump (Standard_OStream& anOS) const
188 {  
189   anOS << "BooleanList";
190   return anOS;
191 }