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