0024814: Avoid using explicit names of Handle classes
[occt.git] / src / DBC / DBC_BaseArray.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15#include <Standard_OutOfRange.hxx>
16#include <Standard_NegativeValue.hxx>
17#include <Standard_NullObject.hxx>
18#include <Standard_NotImplemented.hxx>
19//#include <DBC_DBVArray.hxx>
20#include <DBC_BaseArray.ixx>
21
22#ifdef OBJS
23#include <Standard_Persistent.hxx>
24
25// taille a partir de laquelle la tableau cre son propre container
26//
27#define DBC_TAILLE_PLAFOND_CREATION_SEGMENT 10000
28
29#include <StandardOBJS_PersistentMacro.hxx>
30#include <StandardOBJS_PrimitiveTypes.hxx>
31
32// just use for internal generic identifiaction of Item
33//
34static PStandard_ArrayNode DBC_tmpItem;
35
36#endif
37
38#ifdef OO2
39#include <StandardDB_O2Handle.hxx>
40#endif
41
42// --------------------------------------------------------------------
43// BaseArray implementation : Temporary arrays known as variable-size arrays.
44// BaseArray of BaseArray is not supported in this version.
45//
46// Last Revision : Feb,10 1992 J.P Tirault
47// . Implementation of Lock/Unlock methods :
48// . Implementation of ShallowCopy,ShallowDump,IsSameState.
49//
50// Last Revision : April,4 1992 J.P Tirault, R Barreto
51// . Implementation for Object store.
52// . Implementation for Memory.
53//
54// Last Revision : September,17 1992 J.P Tirault
55// . Free old area in Resize method.
56// Last revision : January,18 1995 N. Massip
57// . Implementation for ObjectStore
58// with an c++ persistent array
59// This version store all the information for the Item
60// in case of non primitive type, the handle, the Standard oid,
61// and the object itself are stored
62// if the oid_standard disapear, it may become interresting to
63// store only the object itself. So a special version who store
64// only the Object is join in comment with each function who
65// may be different, the Haeder of this ccomment is like this :
66//
67// For no Handle Storing
68 /*
69 <code>
70 */
71// Last revision : April 19 1992 N. Massip
72// . Implementation for o2 technology
73// with an o2_array for 4.5
74// should be d_Varray for 4.6
75// Use an Collection of StandardDB_O2Handle
76// for none primitive type to avoid to import
857ffd5e 77// Handle(Standard_Persistent).
7fd59977 78// --------------------------------------------------------------------
79// Last revision : January 1996 JMS/CLE
80// portage OBJY 3.8
81
7fd59977 82// --------------------------------------------------------------------
83// Constructor
84// --------------------------------------------------------------------
85DBC_BaseArray::DBC_BaseArray (const Standard_Integer Size)
86#ifdef OBJY
87 //==== Call the father's constructor.
88 : myData((unsigned int) Size)
89#endif
90
91#ifdef OO2
92 : myData((unsigned int) Size)
93#endif
94{
95 Standard_NegativeValue_Raise_if((Size < 0), "Attempt to create aBaseArray with a bad size");
96 mySize = Size;
97// Standard_Integer i;
98#ifdef OBJSold
99 INTERNAL_MODE_OODB_START {
100 os_segment *seg = Storage_CurrentContainer();
101 if ( Size > DBC_TAILLE_PLAFOND_CREATION_SEGMENT ) {
102 os_database *db = seg->database_of();
103 Storage_CurrentContainer() = db->create_segment();
104 }
105 myData = Standard_PersistentAllocation(DBC_tmpItem, Size);
106 Storage_CurrentContainer() = seg;
107 }
108 INTERNAL_MODE_OODB_END;
109
110#endif
111
112
113}
114
115
116DBC_BaseArray::DBC_BaseArray ()
117
118#ifdef OBJY
119 //==== Call the father's constructor.
120 : myData(0)
121#endif
122
123#ifdef OO2
124 : myData((unsigned int) 0)
125#endif
126{
127 mySize = 0;
128
129#ifdef OBJS
130 myData = NULL;
131#endif
132}
133
134
135// --------------------------------------------------------------------
136// Constructor
137
138// --------------------------------------------------------------------
139DBC_BaseArray::DBC_BaseArray (const DBC_BaseArray& Other)
140#ifdef OBJY
141 //==== Call the father's constructor.
142 : myData(Other.myData)
143#endif
144
145// utilisable pour d_array mais pas o2_list
146#ifdef OO2
147 //==== Call the father's constructor.
148 : myData(Other.myData)
149#endif
150{
151
152 mySize = Other.mySize;
153
154#ifdef OBJSold
155 INTERNAL_MODE_OODB_START {
156 myData = Standard_PersistentAllocation(DBC_tmpItem, mySize);
157 for(Standard_Integer i=0; i<mySize; i++)
158 myData[i] = Other.myData[i];
159 }
160 INTERNAL_MODE_OODB_END;
161#endif
162
163
164}
165
166void DBC_BaseArray::Delete()
167{}
168
169
170// --------------------------------------------------------------------
171// Lock
172//
173// - Call the oodb method update which
174// --------------------------------------------------------------------
175Standard_Address DBC_BaseArray::Lock () const
176{
177#ifdef OBJY
178 return (Standard_Address) &(myData.elem(0));
179#endif
180
181#ifdef OO2
182 return (Standard_Address) &(Value(0));
183#endif
184
185#ifdef OBJS
186 Standard_Address adr;
187 INTERNAL_MODE_OODB_START {
188 adr = (Standard_Address) &myData;
189 }
190 INTERNAL_MODE_OODB_END;
191 return adr;
192#endif
193
194#ifdef CSFDB
195 return (Standard_Address) myData;
196#endif
197}
198
199
200// --------------------------------------------------------------------
201// Unlock
202// --------------------------------------------------------------------
203void DBC_BaseArray::Unlock() const
204{
205}
206
207
208#ifdef OO2
209// Liste de fonctionnalire permettent de manipuler StandardDB_O2Handle et
210// les types primitifs de maniere tranparente
211//
212inline Item &O2Handle_getValue(const StandardDB_O2Handle &val) {
213
214 //Item *hd = (Item *) val.getHandle();
215 //return *hd;
216 return * ((Item *) val.getHandle());
217}
218// polymorphisme avec type primitif
219
220inline Standard_Boolean &O2Handle_getValue(const Standard_Boolean &val) {
221 return (Standard_Boolean) val;
222};
223inline Standard_Integer &O2Handle_getValue(const Standard_Integer &val){
224 return (Standard_Integer) val;
225};
226inline Standard_Real &O2Handle_getValue(const Standard_Real &val){
227 return (Standard_Real) val;
228};
229inline Standard_Character &O2Handle_getValue(const Standard_Character &val){
230 return (Standard_Character) val;
231};
232inline Standard_ExtCharacter &O2Handle_getValue(const Standard_ExtCharacter &val){
233 return (Standard_ExtCharacter) val;
234};
235inline Standard_CString &O2Handle_getValue(const Standard_CString &val){
236 return (Standard_CString) val;
237};
238inline Standard_ExtString &O2Handle_getValue(const Standard_ExtString &val){
239 return (Standard_ExtString) val;
240};
241inline Standard_Address &O2Handle_getValue(const Standard_Address &val){
242 return (Standard_Address ) val;
243};
244inline Standard_ShortReal &O2Handle_getValue(const Standard_ShortReal &val){
245 return (Standard_ShortReal) val;
246};
247#endif
248
249
250