1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
41 OSG_FIELD_CONTAINER_TMPL_NO_TYPE_DEF (SimpleAttachment, AttachmentDescT)
42 OSG_RC_GET_STATIC_TYPE_ID_INL_TMPL_DEF(SimpleAttachment, AttachmentDescT)
44 template <class AttachmentDescT> inline
45 typename SimpleAttachment<AttachmentDescT>::StoredFieldType *
46 SimpleAttachment<AttachmentDescT>::SFieldValFunctions::editFieldPtr(
47 StoredFieldType *pField,
48 SimpleAttachment *pThis )
50 pThis->editSField(SimpleAttachment::SimpleFieldMask);
55 template <class AttachmentDescT> inline
57 SimpleAttachment<AttachmentDescT>::SFieldValFunctions::editHandleField(
58 StoredFieldType *pField,
59 SimpleAttachment *pThis)
61 typename SimpleAttachment::EditHandlePtr returnValue(
62 new typename SimpleAttachment::EditHandle(
64 pThis->getType().getFieldDesc(SimpleAttachment::SimpleFieldId),
67 pThis->editSField(SimpleAttachment::SimpleFieldMask);
72 template <class AttachmentDescT> inline
74 SimpleAttachment<AttachmentDescT>::SFieldValFunctions::syncField(
75 StoredFieldType *pField,
76 StoredFieldType *pSourceField,
77 ConstFieldMaskArg syncMode,
79 AspectOffsetStore &oOffsets )
81 pField->syncWith(*pSourceField);
85 template <class AttachmentDescT> inline
86 typename SimpleAttachment<AttachmentDescT>::StoredFieldType *
87 SimpleAttachment<AttachmentDescT>::SFieldPtrFunctions::editFieldPtr(
88 StoredFieldType *pField,
89 SimpleAttachment *pThis )
94 template <class AttachmentDescT> inline
96 SimpleAttachment<AttachmentDescT>::SFieldPtrFunctions::editHandleField(
97 StoredFieldType *pField,
98 SimpleAttachment *pThis)
100 typename SimpleAttachment::EditHandlePtr returnValue(
101 new typename SimpleAttachment::EditHandle(
103 pThis->getType().getFieldDesc(SimpleAttachment::SimpleFieldId),
106 pThis->editSField(SimpleAttachment::SimpleFieldMask);
108 returnValue->setSetMethod(
109 boost::bind(&SimpleAttachment::setPointerValue, pThis, _1));
114 template <class AttachmentDescT> inline
116 SimpleAttachment<AttachmentDescT>::SFieldPtrFunctions::syncField(
117 StoredFieldType *pField,
118 StoredFieldType *pSourceField,
119 ConstFieldMaskArg syncMode,
121 AspectOffsetStore &oOffsets )
123 pField->syncWith(*pSourceField);
128 template <class AttachmentDescT> inline
129 typename SimpleAttachment<AttachmentDescT>::StoredFieldType *
130 SimpleAttachment<AttachmentDescT>::MFieldValFunctions::editFieldPtr(
131 StoredFieldType *pField,
132 SimpleAttachment *pThis )
134 pThis->editMField(*pField, SimpleAttachment::SimpleFieldMask);
139 template <class AttachmentDescT> inline
141 SimpleAttachment<AttachmentDescT>::MFieldValFunctions::editHandleField(
142 StoredFieldType *pField,
143 SimpleAttachment *pThis)
145 typename SimpleAttachment::EditHandlePtr returnValue(
146 new typename SimpleAttachment::EditHandle(
148 pThis->getType().getFieldDesc(SimpleAttachment::SimpleFieldId),
151 pThis->editMField(*pField, SimpleAttachment::SimpleFieldMask);
156 template <class AttachmentDescT> inline
158 SimpleAttachment<AttachmentDescT>::MFieldValFunctions::syncField(
159 StoredFieldType *pField,
160 StoredFieldType *pSourceField,
161 ConstFieldMaskArg syncMode,
163 AspectOffsetStore &oOffsets )
165 pField->syncWith(*pSourceField, syncMode, uiSyncInfo, oOffsets);
168 template <class AttachmentDescT> inline
169 typename SimpleAttachment<AttachmentDescT>::StoredFieldType *
170 SimpleAttachment<AttachmentDescT>::MFieldPtrFunctions::editFieldPtr(
171 StoredFieldType *pField,
172 SimpleAttachment *pThis )
177 template <class AttachmentDescT> inline
179 SimpleAttachment<AttachmentDescT>::MFieldPtrFunctions::editHandleField(
180 StoredFieldType *pField,
181 SimpleAttachment *pThis)
183 typename SimpleAttachment::EditHandlePtr returnValue(
184 new typename SimpleAttachment::EditHandle(
186 pThis->getType().getFieldDesc(SimpleAttachment::SimpleFieldId),
189 pThis->editMField(*pField, SimpleAttachment::SimpleFieldMask);
191 returnValue->setSetMethod(
192 boost::bind(&SimpleAttachment::addPointerValue, pThis, _1));
197 template <class AttachmentDescT> inline
199 SimpleAttachment<AttachmentDescT>::MFieldPtrFunctions::syncField(
200 StoredFieldType *pField,
201 StoredFieldType *pSourceField,
202 ConstFieldMaskArg syncMode,
204 AspectOffsetStore &oOffsets )
206 pField->syncWith(*pSourceField, syncMode, uiSyncInfo, oOffsets);
210 template <class AttachmentDescT> inline
211 typename SimpleAttachment<AttachmentDescT>::StoredFieldType *
212 SimpleAttachment<AttachmentDescT>::editFieldPtr(void)
214 return FieldFunctions::editFieldPtr(&_field, this);
217 template <class AttachmentDescT> inline
218 const typename SimpleAttachment<AttachmentDescT>::StoredFieldType *
219 SimpleAttachment<AttachmentDescT>::getFieldPtr(void) const
224 template <class AttachmentDescT> inline
225 const typename SimpleAttachment<AttachmentDescT>::StoredFieldType &
226 SimpleAttachment<AttachmentDescT>::getField(void) const
231 template <class AttachmentDescT> inline
232 Char8 *SimpleAttachment<AttachmentDescT>::getClassname(void)
234 return SimpleDesc::getTypeName();
237 template <class AttachmentDescT> inline
238 SimpleAttachment<AttachmentDescT>::SimpleAttachment(void) :
244 template <class AttachmentDescT> inline
245 SimpleAttachment<AttachmentDescT>::SimpleAttachment(
246 const SimpleAttachment &source) :
249 _field (source._field)
253 template <class AttachmentDescT> inline
254 SimpleAttachment<AttachmentDescT>::~SimpleAttachment(void)
258 #ifdef OSG_MT_CPTR_ASPECT
259 template <class AttachmentDescT> inline
260 void SimpleAttachment<AttachmentDescT>::execSync(
261 SimpleAttachment *pFrom,
262 ConstFieldMaskArg whichField,
263 AspectOffsetStore &oOffsets,
264 ConstFieldMaskArg syncMode ,
265 const UInt32 uiSyncInfo)
267 // At least sync the parents for now
268 Inherited::execSync(pFrom,
274 if(FieldBits::NoField != (SimpleFieldMask & whichField))
276 FieldFunctions::syncField(&_field,
284 template <class AttachmentDescT> inline
285 void SimpleAttachment<AttachmentDescT>::execSyncV(
286 FieldContainer &oFrom,
287 ConstFieldMaskArg whichField,
288 AspectOffsetStore &oOffsets,
289 ConstFieldMaskArg syncMode ,
290 const UInt32 uiSyncInfo)
292 this->execSync(static_cast<SimpleAttachment *>(&oFrom),
300 #ifdef OSG_MT_CPTR_ASPECT
301 template <class AttachmentDescT> inline
302 typename SimpleAttachment<AttachmentDescT>::ObjCPtr
303 SimpleAttachment<AttachmentDescT>::createAspectCopy(
304 const FieldContainer *pRefAspect) const
308 newAspectCopy(returnValue,
309 dynamic_cast<const Self *>(pRefAspect),
310 dynamic_cast<const Self *>(this));
316 template <class AttachmentDescT> inline
317 SizeT SimpleAttachment<AttachmentDescT>::getBinSize(
318 ConstFieldMaskArg whichField)
320 SizeT returnValue = Inherited::getBinSize(whichField);
322 if(FieldBits::NoField != (SimpleFieldMask & whichField))
324 returnValue += _field.getBinSize();
331 template <class AttachmentDescT> inline
332 void SimpleAttachment<AttachmentDescT>::copyToBin(
333 BinaryDataHandler &pMem,
334 ConstFieldMaskArg whichField)
336 Inherited::copyToBin(pMem, whichField);
338 if(FieldBits::NoField != (SimpleFieldMask & whichField))
340 _field.copyToBin(pMem);
344 template <class AttachmentDescT> inline
345 void SimpleAttachment<AttachmentDescT>::copyFromBin(
346 BinaryDataHandler &pMem,
347 ConstFieldMaskArg whichField)
349 Inherited::copyFromBin(pMem, whichField);
351 if(FieldBits::NoField != (SimpleFieldMask & whichField))
353 _field.copyFromBin(pMem);
357 template <class AttachmentDescT> inline
358 void SimpleAttachment<AttachmentDescT>::dump(
360 const BitVector) const
364 template <class AttachmentDescT> inline
365 GetFieldHandlePtr SimpleAttachment<AttachmentDescT>::getHandleField(void) const
367 GetHandlePtr returnValue(
370 this->getType().getFieldDesc(SimpleFieldId),
371 const_cast<Self *>(this)));
376 template <class AttachmentDescT> inline
377 EditFieldHandlePtr SimpleAttachment<AttachmentDescT>::editHandleField(void)
380 EditHandlePtr returnValue(
383 this->getType().getFieldDesc(SimpleFieldId),
386 // editSField(TravMaskFieldMask);
388 // return returnValue;
390 return FieldFunctions::editHandleField(&_field, this);
393 template <class AttachmentDescT> inline
394 void SimpleAttachment<AttachmentDescT>::setPointerValue(ArgumentType pVal)
396 OSG::setRefd(_field.getValue(), pVal);
399 template <class AttachmentDescT> inline
400 void SimpleAttachment<AttachmentDescT>::addPointerValue(ArgumentType pVal)
404 _field.push_back(pVal);