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 /*---------------------------------------------------------------------------*/
42 /* GetSFieldHandle<FieldContainerPtrSFieldBase> */
43 /*---------------------------------------------------------------------------*/
45 /*---------------------------------------------------------------------------*/
49 GetSFieldHandle<FieldContainerPtrSFieldBase>::GetSFieldHandle(
50 const GetSFieldHandle &source) :
57 GetSFieldHandle<FieldContainerPtrSFieldBase>::GetSFieldHandle(
58 const FieldContainerPtrSFieldBase *pField,
59 const FieldDescriptionBase *pDescription,
60 FieldContainer *pContainer ) :
62 Inherited(pField, pDescription, pContainer)
66 /*---------------------------------------------------------------------------*/
67 /* Field Type Query */
71 GetSFieldHandle<FieldContainerPtrSFieldBase>::getType(void) const
73 return FieldContainerPtrSFieldBase::getClassType();
77 bool GetSFieldHandle<FieldContainerPtrSFieldBase>::isPointerField(void) const
82 /*---------------------------------------------------------------------------*/
83 /* Stream/String IO */
86 void GetSFieldHandle<FieldContainerPtrSFieldBase>::pushValueToStream(
89 FWARNING(("illegal pushValueToStream called for %s\n",
90 this->getName().c_str()));
95 void GetSFieldHandle<FieldContainerPtrSFieldBase>::pushSizeToStream(
98 FWARNING(("illegal pushSizeToStream called for %s\n",
99 this->getName().c_str()));
104 void GetSFieldHandle<FieldContainerPtrSFieldBase>::pushIndexedValueToStream(
108 FWARNING(("illegal pushIndexedValueToStream called for %s\n",
109 this->getName().c_str()));
113 /*---------------------------------------------------------------------------*/
117 bool GetSFieldHandle<FieldContainerPtrSFieldBase>::equal(
118 Inherited::Ptr rhs) const
120 Ptr pOther = boost::dynamic_pointer_cast<GetSFieldHandle>(rhs);
127 FieldContainerPtrSFieldBase const *pLhs =
128 static_cast<FieldContainerPtrSFieldBase const *>( _pField);
130 FieldContainerPtrSFieldBase const *pRhs =
131 static_cast<FieldContainerPtrSFieldBase const *>(pOther->_pField);
133 return (*pLhs) == (*pRhs);
137 SizeT GetSFieldHandle<FieldContainerPtrSFieldBase>::size(void) const
142 /*---------------------------------------------------------------------------*/
146 const FieldContainerPtrSFieldBase *
147 GetSFieldHandle<FieldContainerPtrSFieldBase>::getField(void)
149 return static_cast<const FieldContainerPtrSFieldBase *>(_pField);
153 const FieldContainerPtrSFieldBase *
154 GetSFieldHandle<FieldContainerPtrSFieldBase>::operator ->(void)
156 return static_cast<const FieldContainerPtrSFieldBase *>(_pField);
160 const FieldContainerPtrSFieldBase &
161 GetSFieldHandle<FieldContainerPtrSFieldBase>::operator * (void)
163 return *(static_cast<const FieldContainerPtrSFieldBase *>(_pField));
166 /*---------------------------------------------------------------------------*/
167 /* EditSFieldHandle<FieldContainerPtrSFieldBase> */
168 /*---------------------------------------------------------------------------*/
170 /*---------------------------------------------------------------------------*/
174 EditSFieldHandle<FieldContainerPtrSFieldBase>::EditSFieldHandle(
175 const EditSFieldHandle &source) :
178 _bStoreless(source._bStoreless)
183 EditSFieldHandle<FieldContainerPtrSFieldBase>::EditSFieldHandle(
184 FieldContainerPtrSFieldBase *pField,
185 const FieldDescriptionBase *pDescription,
186 FieldContainer *pContainer ) :
196 bool EditSFieldHandle<FieldContainerPtrSFieldBase>::isValid(void) const
198 BitVector accessFlags = _pDescription->getFlags() & Field::FAccessMask;
201 ( (_pField != NULL) ||
202 ((_bStoreless == true) && (0x0000 != (accessFlags &
203 Field::FCustomAccess))));
207 void EditSFieldHandle<FieldContainerPtrSFieldBase>::setStoreless(void)
212 /*---------------------------------------------------------------------------*/
213 /* Field Type Query */
217 EditSFieldHandle<FieldContainerPtrSFieldBase>::getType(void) const
219 return FieldContainerPtrSFieldBase::getClassType();
223 bool EditSFieldHandle<FieldContainerPtrSFieldBase>::isPointerField(void) const
228 /*---------------------------------------------------------------------------*/
229 /* Stream/String IO */
232 void EditSFieldHandle<FieldContainerPtrSFieldBase>::pushValueToStream(
233 OutStream &str) const
235 FWARNING(("illegal pushValueToStream called for %s\n",
236 this->getName().c_str()));
241 void EditSFieldHandle<FieldContainerPtrSFieldBase>::pushSizeToStream(
242 OutStream &str) const
244 FWARNING(("illegal pushSizeToStream called for %s\n",
245 this->getName().c_str()));
250 void EditSFieldHandle<FieldContainerPtrSFieldBase>::pushIndexedValueToStream(
254 FWARNING(("illegal pushIndexedValueToStream called for %s\n",
255 this->getName().c_str()));
261 void EditSFieldHandle<FieldContainerPtrSFieldBase>::pushValueFromCString(
264 FWARNING(("illegal pushValueFromCString called for %s\n",
265 this->getName().c_str()));
270 void EditSFieldHandle<FieldContainerPtrSFieldBase>::pushIndexedValueFromCString(
274 FWARNING(("illegal pushIndexedValueFromCString called for %s\n",
275 this->getName().c_str()));
279 /*---------------------------------------------------------------------------*/
283 bool EditSFieldHandle<FieldContainerPtrSFieldBase>::equal(
284 Inherited::Ptr rhs) const
286 Ptr pOther = boost::dynamic_pointer_cast<EditSFieldHandle>(rhs);
293 FieldContainerPtrSFieldBase *pLhs =
294 static_cast<FieldContainerPtrSFieldBase *>( _pField);
296 FieldContainerPtrSFieldBase *pRhs =
297 static_cast<FieldContainerPtrSFieldBase *>(pOther->_pField);
299 return (*pLhs) == (*pRhs);
303 SizeT EditSFieldHandle<FieldContainerPtrSFieldBase>::size(void) const
308 /*---------------------------------------------------------------------------*/
309 /* Copy/Share/Clone */
312 void EditSFieldHandle<FieldContainerPtrSFieldBase>::copyValues(
313 GetFieldHandlePtr source) const
315 FWARNING(("illegal copyValues called for %s\n",
316 this->getName().c_str()));
321 void EditSFieldHandle<FieldContainerPtrSFieldBase>::shareValues(
322 GetFieldHandlePtr source) const
328 void EditSFieldHandle<FieldContainerPtrSFieldBase>::cloneValues(
329 GetFieldHandlePtr pSrc,
330 const TypePtrVector &shareTypes,
331 const TypePtrVector &ignoreTypes,
332 const TypeIdVector &shareGroupIds,
333 const TypeIdVector &ignoreGroupIds) const
338 /*---------------------------------------------------------------------------*/
339 /* GetFCPtrSFieldHandle<FieldT> */
340 /*---------------------------------------------------------------------------*/
342 /*---------------------------------------------------------------------------*/
345 template <class FieldT> inline
346 GetFCPtrSFieldHandle<FieldT>::GetFCPtrSFieldHandle(
347 const GetFCPtrSFieldHandle &source) :
353 template <class FieldT> inline
354 GetFCPtrSFieldHandle<FieldT>::GetFCPtrSFieldHandle(
355 const FieldT *pField,
356 const FieldDescriptionBase *pDescription,
357 FieldContainer *pContainer ) :
359 Inherited(pField, pDescription, pContainer)
363 /*---------------------------------------------------------------------------*/
364 /* Field Type Query */
366 template <class FieldT> inline
367 const FieldType &GetFCPtrSFieldHandle<FieldT>::getType(void) const
369 return FieldT::getClassType();
372 /*---------------------------------------------------------------------------*/
373 /* Stream/String IO */
375 template <class FieldT> inline
376 void GetFCPtrSFieldHandle<FieldT>::pushValueToStream(OutStream &str) const
378 FWARNING(("illegal pushValueToStream called for %s\n",
379 this->getName().c_str()));
382 // OSG_ASSERT(false);
385 template <class FieldT> inline
386 void GetFCPtrSFieldHandle<FieldT>::pushSizeToStream(OutStream &str) const
388 FWARNING(("illegal pushSizeToStream called for %s\n",
389 this->getName().c_str()));
393 /*---------------------------------------------------------------------------*/
396 template <class FieldT> inline
397 FieldContainer *GetFCPtrSFieldHandle<FieldT>::get(void) const
399 return dcast_const()->getValue();
402 template <class FieldT> inline
403 const FieldT *GetFCPtrSFieldHandle<FieldT>::getField(void)
405 return static_cast<const FieldT *>(_pField);
408 template <class FieldT> inline
409 const FieldT *GetFCPtrSFieldHandle<FieldT>::operator ->(void)
411 return static_cast<const FieldT *>(_pField);
414 template <class FieldT> inline
415 const FieldT &GetFCPtrSFieldHandle<FieldT>::operator * (void)
417 return *(static_cast<const FieldT *>(_pField));
420 /*---------------------------------------------------------------------------*/
423 template <class FieldT> inline
424 const typename GetFCPtrSFieldHandle<FieldT>::HandledField *
425 GetFCPtrSFieldHandle<FieldT>::dcast_const(void) const
427 return static_cast<const HandledField *>(_pField);
430 /*---------------------------------------------------------------------------*/
431 /* EditFCPtrSFieldHandle<FieldT> */
432 /*---------------------------------------------------------------------------*/
434 /*---------------------------------------------------------------------------*/
437 template <class FieldT> inline
438 EditFCPtrSFieldHandle<FieldT>::EditFCPtrSFieldHandle(
439 const EditFCPtrSFieldHandle &source) :
442 _fSetMethod(source._fSetMethod)
446 template <class FieldT> inline
447 EditFCPtrSFieldHandle<FieldT>::EditFCPtrSFieldHandle(
449 const FieldDescriptionBase *pDescription,
450 FieldContainer *pContainer ) :
459 /*---------------------------------------------------------------------------*/
460 /* Field Type Query */
462 template <class FieldT> inline
463 const FieldType &EditFCPtrSFieldHandle<FieldT>::getType(void) const
465 return FieldT::getClassType();
468 template <class FieldT> inline
469 bool EditFCPtrSFieldHandle<FieldT>::supportsSet(void) const
471 BitVector accessFlags = _pDescription->getFlags() & Field::FAccessMask;
474 ((0x0000 != (accessFlags & Field::FStdAccess ) ||
475 0x0000 != (accessFlags & Field::FNullCheckAccess) ) ||
476 (0x0000 != (accessFlags & Field::FCustomAccess ) &&
477 !_fSetMethod.empty() ) );
480 /*---------------------------------------------------------------------------*/
483 template <class FieldT> inline
484 FieldContainer *EditFCPtrSFieldHandle<FieldT>::get(void) const
486 return dcast_const()->getValue();
489 template <class FieldT>
490 bool EditFCPtrSFieldHandle<FieldT>::set(FieldContainer *newFC) const
493 typename FieldT::const_value typedNewFC =
494 dynamic_cast<typename FieldT::const_value>(newFC);
495 BitVector accessFlags =
496 _pDescription->getFlags() & Field::FAccessMask;
498 if(0x0000 != (accessFlags & Field::FCustomAccess))
500 if(typedNewFC != NULL || newFC == NULL)
502 if(!_fSetMethod.empty())
504 _fSetMethod(typedNewFC);
509 FFATAL(("EditFCPtrSFieldHandle<FieldT>::set called, but "
510 "_fSetMethod is not set.\n"));
514 else if(0x0000 != (accessFlags & Field::FNullCheckAccess))
516 if(typedNewFC != NULL)
518 dcast()->setValue(typedNewFC);
522 else if(0x0000 != (accessFlags & Field::FStdAccess))
524 if(typedNewFC != NULL || newFC == NULL)
526 dcast()->setValue(typedNewFC);
532 // this should never happen
533 FFATAL(("EditFCPtrSFieldHandle<FieldT>::set: Field has unknown access.\n"));
539 /*---------------------------------------------------------------------------*/
540 /* Stream/String IO */
542 template <class FieldT> inline
543 void EditFCPtrSFieldHandle<FieldT>::pushValueToStream(OutStream &str) const
545 FWARNING(("illegal pushValueToStream called for %s\n",
546 this->getName().c_str()));
551 template <class FieldT> inline
552 void EditFCPtrSFieldHandle<FieldT>::pushSizeToStream(OutStream &str) const
554 FWARNING(("illegal pushSizeToStream called for %s\n",
555 this->getName().c_str()));
559 template <class FieldT> inline
560 void EditFCPtrSFieldHandle<FieldT>::pushValueFromCString(const Char8 *str)
562 FWARNING(("illegal pushValueFromCString called for %s\n",
563 this->getName().c_str()));
567 /*---------------------------------------------------------------------------*/
570 template <class FieldT> inline
571 void EditFCPtrSFieldHandle<FieldT>::setSetMethod(SetMethod fMethod)
573 _fSetMethod = fMethod;
576 /*---------------------------------------------------------------------------*/
577 /* Copy/Share/Clone */
579 template <class FieldT> inline
580 void EditFCPtrSFieldHandle<FieldT>::copyValues(GetFieldHandlePtr source) const
582 FWARNING(("illegal copyValues called for %s\n",
583 this->getName().c_str()));
587 template <class FieldT> inline
588 void EditFCPtrSFieldHandle<FieldT>::shareValues(GetFieldHandlePtr source) const
590 typename Self::GetSFHandlePtr pSrcBase =
591 boost::dynamic_pointer_cast<GetSFHandle>(source);
593 if(pSrcBase != NULL && pSrcBase->isValid() == true)
595 this->set(pSrcBase->get());
599 FWARNING(("shareValues illegal source for %s\n",
600 this->getName().c_str()));
604 template <class FieldT> inline
605 void EditFCPtrSFieldHandle<FieldT>::cloneValues(
606 GetFieldHandlePtr pSrc,
607 const TypePtrVector &shareTypes,
608 const TypePtrVector &ignoreTypes,
609 const TypeIdVector &shareGroupIds,
610 const TypeIdVector &ignoreGroupIds) const
612 typename Self::GetSFHandlePtr pSrcBase =
613 boost::dynamic_pointer_cast<GetSFHandle>(pSrc);
615 if(pSrcBase != NULL && pSrcBase->isValid() == true)
617 StoredPtrType pSrcTyped = dynamic_cast<StoredPtrType>(pSrcBase->get());
619 if(pSrcTyped != NULL)
621 FieldContainerUnrecPtr pDst = deepClone(pSrcTyped,
632 FWARNING(("cloneValues illegal source for %s\n",
633 this->getName().c_str()));
637 /*---------------------------------------------------------------------------*/
640 template <class FieldT> inline
641 typename EditFCPtrSFieldHandle<FieldT>::HandledField *
642 EditFCPtrSFieldHandle<FieldT>::dcast(void) const
644 return static_cast<HandledField *>(_pField);
647 template <class FieldT> inline
648 const typename EditFCPtrSFieldHandle<FieldT>::HandledField *
649 EditFCPtrSFieldHandle<FieldT>::dcast_const(void) const
651 return static_cast<const HandledField *>(_pField);