fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Test / SystemLib / OSGTestFC.cpp
blobb60704def37b7871451eea582226a2206897cc69
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <stdlib.h>
44 #include <stdio.h>
46 #include "OSGConfig.h"
48 #include "OSGLog.h"
49 #include "OSGContainerPtrFuncs.h"
50 #include "OSGTestFC.h"
52 OSG_USING_NAMESPACE
54 void TestFC::classDescInserter(TypeObject &oType)
56 FieldDescriptionBase *pDesc = NULL;
58 pDesc = new MFUInt32::Description(
59 MFUInt32::getClassType(),
60 "field1",
61 "",
62 OSG_RC_FIELD_DESC(TestFC::Field1),
63 false,
64 Field::MFDefaultFlags,
65 reinterpret_cast<FieldEditMethodSig>(&TestFC::editHandleField1),
66 reinterpret_cast<FieldGetMethodSig >(&TestFC::getHandleField1 ));
68 oType.addInitialDesc(pDesc);
70 pDesc = new SFUInt32::Description(
71 SFUInt32::getClassType(),
72 "field2",
73 "",
74 OSG_RC_FIELD_DESC(TestFC::Field2),
75 false,
76 Field::SFDefaultFlags,
77 reinterpret_cast<FieldEditMethodSig>(&TestFC::editHandleField2),
78 reinterpret_cast<FieldGetMethodSig >(&TestFC::getHandleField2 ));
80 oType.addInitialDesc(pDesc);
82 pDesc = new MFUInt32::Description(
83 MFUInt32::getClassType(),
84 "field3",
85 "",
86 OSG_RC_FIELD_DESC(TestFC::Field3),
87 false,
88 Field::MFDefaultFlags,
89 reinterpret_cast<FieldEditMethodSig>(&TestFC::editHandleField3),
90 reinterpret_cast<FieldGetMethodSig >(&TestFC::getHandleField3 ));
92 oType.addInitialDesc(pDesc);
94 pDesc = new SFUInt32::Description(
95 SFUInt32::getClassType(),
96 "field4",
97 "",
98 OSG_RC_FIELD_DESC(TestFC::Field4),
99 false,
100 Field::SFDefaultFlags,
101 reinterpret_cast<FieldEditMethodSig>(&TestFC::editHandleField4),
102 reinterpret_cast<FieldGetMethodSig >(&TestFC::getHandleField4 ));
104 oType.addInitialDesc(pDesc);
107 TestFC::TypeObject TestFC::_type(
108 TestFC ::getClassname(),
109 Inherited::getClassname(),
110 "Test",
112 reinterpret_cast<PrototypeCreateF>(&TestFC::createEmptyLocal),
113 NULL,
114 NULL,
115 reinterpret_cast<InitalInsertDescFunc>(&TestFC::classDescInserter),
116 false,
120 OSG_FIELD_CONTAINER_DEF(TestFC)
122 /*-------------------------------------------------------------------------*/
123 /* Set */
125 /*-------------------------------------------------------------------------*/
126 /* Constructors */
128 TestFC::TestFC(void) :
129 Inherited(),
130 _mfField1 (),
131 _sfField2 (),
132 _mfField3 (),
133 _sfField4 ()
137 TestFC::TestFC(const TestFC &source) :
138 Inherited(source ),
139 _mfField1 (source._mfField1),
140 _sfField2 (source._sfField2),
141 _mfField3 (source._mfField3),
142 _sfField4 (source._sfField4)
145 /*-------------------------------------------------------------------------*/
146 /* Destructor */
148 TestFC::~TestFC(void)
152 void TestFC::onDestroyAspect(UInt32 uiContainerId,
153 UInt32 uiAspect )
155 // _mfField1.terminateShare(uiAspect, getContainerSize());
156 // _mfField3.terminateShare(uiAspect, getContainerSize());
159 #ifdef OSG_MT_CPTR_ASPECT
160 TestFC::ObjCPtr TestFC::createAspectCopy(const FieldContainer *pRefAspect) const
162 TestFC *returnValue;
164 newAspectCopy(returnValue,
165 dynamic_cast<const TestFC *>(pRefAspect),
166 dynamic_cast<const TestFC *>(this));
168 return returnValue;
170 #endif
172 void TestFC::changed(ConstFieldMaskArg whichField,
173 UInt32 origin,
174 BitVector details)
176 fprintf(stderr, "TestFC changed\n");
178 Inherited::changed(whichField, origin, details);
181 void TestFC::dump( UInt32 uiIndent,
182 const BitVector bvFlags ) const
184 #ifdef OSG_MT_CPTR_ASPECT
185 fprintf(stderr, "TestFC %p %p\n", this, _pAspectStore);
187 _pAspectStore->dump();
188 #endif
190 fprintf(stderr, "%p %p | 0x%016" PRIx64 "\n",
191 _pContainerChanges,
192 &_bvChanged,
193 _bvChanged);
195 _mfField1.dump(uiIndent + 4, bvFlags);
197 for(UInt32 i = 0; i < _mfField1.size(); ++i)
199 fprintf(stderr, "%d ", _mfField1[i]);
201 fprintf(stderr, "\n");
203 fprintf(stderr, "%d\n", _sfField2.getValue());
205 _mfField3.dump(uiIndent + 4, bvFlags);
207 for(UInt32 i = 0; i < _mfField3.size(); ++i)
209 fprintf(stderr, "%d ", _mfField3[i]);
211 fprintf(stderr, "\n");
214 MFUInt32 *TestFC::editMFField1(void)
216 editMField(Field1FieldMask, _mfField1);
218 return &_mfField1;
221 const MFUInt32 *TestFC::getMFField1(void) const
223 return &_mfField1;
226 SFUInt32 *TestFC::editSFField2(void)
228 editSField(Field2FieldMask);
230 return &_sfField2;
233 const SFUInt32 *TestFC::getSFField2(void) const
235 return &_sfField2;
238 MFUInt32 *TestFC::editMFField3(void)
240 editMField(Field3FieldMask, _mfField3);
242 return &_mfField3;
245 const MFUInt32 *TestFC::getMFField3(void) const
247 return &_mfField3;
250 SFUInt32 *TestFC::editSFField4(void)
252 editSField(Field4FieldMask);
254 return &_sfField4;
257 const SFUInt32 *TestFC::getSFField4(void) const
259 return &_sfField4;
262 /*-------------------------------------------------------------------------*/
263 /* Assignment */
265 #ifdef OSG_MT_CPTR_ASPECT
266 void TestFC::execSyncV( FieldContainer &oFrom,
267 ConstFieldMaskArg whichField,
268 AspectOffsetStore &oOffsets,
269 ConstFieldMaskArg syncMode ,
270 const UInt32 uiSyncInfo)
272 this->execSync(static_cast<TestFC *>(&oFrom),
273 whichField,
274 oOffsets,
275 syncMode,
276 uiSyncInfo);
278 #endif
280 void TestFC::resolveLinks(void)
282 Inherited::resolveLinks();
285 /*-------------------------------------------------------------------------*/
286 /* Comparison */
288 MFUInt32::EditHandlePtr TestFC::editHandleField1(void)
290 MFUInt32::EditHandlePtr returnValue(
291 new MFUInt32::EditHandle(
292 &_mfField1,
293 this->getType().getFieldDesc(Field1FieldId),
294 this));
296 editMField(Field1FieldMask, _mfField1);
298 return returnValue;
301 MFUInt32::GetHandlePtr TestFC::getHandleField1 (void) const
303 MFUInt32::GetHandlePtr returnValue(
304 new MFUInt32::GetHandle(
305 &_mfField1,
306 this->getType().getFieldDesc(Field1FieldId),
307 const_cast<TestFC *>(this)));
309 return returnValue;
312 SFUInt32::EditHandlePtr TestFC::editHandleField2(void)
314 SFUInt32::EditHandlePtr returnValue(
315 new SFUInt32::EditHandle(
316 &_sfField2,
317 this->getType().getFieldDesc(Field2FieldId),
318 this));
320 editSField(Field2FieldMask);
322 return returnValue;
325 SFUInt32::GetHandlePtr TestFC::getHandleField2 (void) const
327 SFUInt32::GetHandlePtr returnValue(
328 new SFUInt32::GetHandle(
329 &_sfField2,
330 this->getType().getFieldDesc(Field2FieldId),
331 const_cast<TestFC *>(this)));
333 return returnValue;
337 MFUInt32::EditHandlePtr TestFC::editHandleField3(void)
339 MFUInt32::EditHandlePtr returnValue(
340 new MFUInt32::EditHandle(
341 &_mfField3,
342 this->getType().getFieldDesc(Field3FieldId),
343 this));
345 editMField(Field3FieldMask, _mfField3);
347 return returnValue;
350 MFUInt32::GetHandlePtr TestFC::getHandleField3 (void) const
352 MFUInt32::GetHandlePtr returnValue(
353 new MFUInt32::GetHandle(
354 &_mfField3,
355 this->getType().getFieldDesc(Field3FieldId),
356 const_cast<TestFC *>(this)));
358 return returnValue;
361 SFUInt32::EditHandlePtr TestFC::editHandleField4(void)
363 SFUInt32::EditHandlePtr returnValue(
364 new SFUInt32::EditHandle(
365 &_sfField4,
366 this->getType().getFieldDesc(Field4FieldId),
367 this));
369 editSField(Field4FieldMask);
371 return returnValue;
374 SFUInt32::GetHandlePtr TestFC::getHandleField4 (void) const
376 SFUInt32::GetHandlePtr returnValue(
377 new SFUInt32::GetHandle(
378 &_sfField4,
379 this->getType().getFieldDesc(Field4FieldId),
380 const_cast<TestFC *>(this)));
382 return returnValue;