summaryrefslogtreecommitdiff
path: root/src/DBC/DBC_BaseArray.cxx
blob: d4c0b4e44dba68e58a1562ee299a0adf2d1c2cab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#include <Standard_OutOfRange.hxx> 
#include <Standard_NegativeValue.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_NotImplemented.hxx>
//#include <DBC_DBVArray.hxx>
#include <DBC_BaseArray.ixx>

#ifdef OBJS
#include <Standard_Persistent.hxx>

// taille a partir de laquelle la tableau cre son propre container
//
#define DBC_TAILLE_PLAFOND_CREATION_SEGMENT 10000 

#include <StandardOBJS_PersistentMacro.hxx>
#include <StandardOBJS_PrimitiveTypes.hxx>

// just use for internal generic identifiaction of Item
//
static PStandard_ArrayNode DBC_tmpItem;

#endif

#ifdef OO2
#include <StandardDB_O2Handle.hxx>
#endif

// --------------------------------------------------------------------
// BaseArray implementation  : Temporary arrays known as variable-size arrays.
//                          BaseArray of BaseArray is not supported in this version.
// 
// Last Revision : Feb,10 1992 J.P Tirault
//                 . Implementation of Lock/Unlock methods :
//                 . Implementation of ShallowCopy,ShallowDump,IsSameState.
//                               
// Last Revision : April,4 1992 J.P Tirault, R Barreto
//                 . Implementation for Object store.
//                 . Implementation for Memory.
//                               
// Last Revision : September,17 1992 J.P Tirault
//                 . Free old area in Resize method. 
// Last revision : January,18 1995 N. Massip
//                   . Implementation for ObjectStore 
//		     with an c++ persistent array
//   This version store all the information for the Item
// in case of non primitive type, the handle, the Standard oid,
// and the object itself are stored
// if the oid_standard disapear, it may become interresting to
// store only the object itself. So a special version who store
// only the Object is join in comment with each function who
// may be different, the Haeder of this ccomment is like this :
//
//   For no Handle Storing
     /*
	<code>
     */
//   Last revision : April 19 1992 N. Massip
//                     . Implementation for o2 technology
//                     with an o2_array for 4.5
//                     should be d_Varray for 4.6
//                Use an Collection of StandardDB_O2Handle
//                for none primitive type to avoid to import
//                Handle_Standard_Persistent.
// --------------------------------------------------------------------
//   Last revision : January 1996 JMS/CLE
//                   portage OBJY 3.8




// --------------------------------------------------------------------
//                                 ShallowDump
// --------------------------------------------------------------------
//void DBC_BaseArray::ShallowDump( Standard_OStream& S) const
void DBC_BaseArray::ShallowDump( Standard_OStream& ) const
{
}


// --------------------------------------------------------------------
//                                  Constructor
// --------------------------------------------------------------------
DBC_BaseArray::DBC_BaseArray (const Standard_Integer Size) 
#ifdef OBJY
     //==== Call the father's constructor.
     : myData((unsigned int) Size)
#endif

#ifdef OO2
     : myData((unsigned int) Size)
#endif
{
  Standard_NegativeValue_Raise_if((Size < 0), "Attempt to create aBaseArray with a bad size");
  mySize = Size;
// Standard_Integer i;
#ifdef OBJSold
  INTERNAL_MODE_OODB_START {
    os_segment *seg = Storage_CurrentContainer(); 
    if ( Size > DBC_TAILLE_PLAFOND_CREATION_SEGMENT ) { 
      os_database *db = seg->database_of();
      Storage_CurrentContainer() = db->create_segment();
    }        
    myData = Standard_PersistentAllocation(DBC_tmpItem, Size);
    Storage_CurrentContainer() = seg;
  }
  INTERNAL_MODE_OODB_END;
  
#endif


}


DBC_BaseArray::DBC_BaseArray () 

#ifdef OBJY
   //==== Call the father's constructor.
   : myData(0)
#endif

#ifdef OO2
     : myData((unsigned int) 0)
#endif
{
  mySize = 0;

#ifdef OBJS
  myData = NULL;
#endif
}


// --------------------------------------------------------------------
//                                  Constructor

// --------------------------------------------------------------------
DBC_BaseArray::DBC_BaseArray (const DBC_BaseArray& Other) 
#ifdef OBJY
     //==== Call the father's constructor.
     : myData(Other.myData)
#endif

// utilisable pour d_array mais pas o2_list
#ifdef OO2
     //==== Call the father's constructor.
     : myData(Other.myData)
#endif
{

  mySize = Other.mySize;

#ifdef OBJSold
  INTERNAL_MODE_OODB_START {    
    myData = Standard_PersistentAllocation(DBC_tmpItem, mySize);
    for(Standard_Integer i=0; i<mySize; i++)
      myData[i] = Other.myData[i];
  }
  INTERNAL_MODE_OODB_END;   
#endif


}

void DBC_BaseArray::Delete()
{}


// --------------------------------------------------------------------
//                                  Lock
//
//   - Call the oodb method update which 
// --------------------------------------------------------------------
Standard_Address DBC_BaseArray::Lock () const
{
#ifdef OBJY
  return (Standard_Address) &(myData.elem(0));
#endif

#ifdef OO2
  return (Standard_Address) &(Value(0));
#endif

#ifdef OBJS
  Standard_Address adr;
  INTERNAL_MODE_OODB_START {
    adr = (Standard_Address) &myData;
  }
  INTERNAL_MODE_OODB_END;
  return adr;
#endif

#ifdef CSFDB
  return (Standard_Address) myData;
#endif
}


// --------------------------------------------------------------------
//                                  Unlock
// --------------------------------------------------------------------
void DBC_BaseArray::Unlock() const
{
}


#ifdef OO2
// Liste de fonctionnalire permettent de manipuler StandardDB_O2Handle et
// les types primitifs de maniere tranparente
//
inline Item &O2Handle_getValue(const StandardDB_O2Handle &val) {

  //Item *hd = (Item *) val.getHandle();
  //return *hd; 
  return * ((Item *) val.getHandle());
}
// polymorphisme avec type primitif

inline Standard_Boolean      &O2Handle_getValue(const Standard_Boolean &val) {
  return (Standard_Boolean) val;
};
inline Standard_Integer      &O2Handle_getValue(const Standard_Integer &val){
  return (Standard_Integer) val;
};
inline Standard_Real         &O2Handle_getValue(const Standard_Real &val){
  return (Standard_Real) val;
};
inline Standard_Character    &O2Handle_getValue(const Standard_Character &val){
  return (Standard_Character) val;
};
inline Standard_ExtCharacter &O2Handle_getValue(const Standard_ExtCharacter &val){
  return (Standard_ExtCharacter) val;
};
inline Standard_CString      &O2Handle_getValue(const Standard_CString &val){
  return (Standard_CString) val;
};
inline Standard_ExtString    &O2Handle_getValue(const Standard_ExtString &val){
  return (Standard_ExtString) val;
};
inline Standard_Address      &O2Handle_getValue(const Standard_Address &val){
  return (Standard_Address ) val;
};
inline Standard_ShortReal    &O2Handle_getValue(const Standard_ShortReal &val){
  return (Standard_ShortReal) val;
};
#endif