1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2008 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 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGCHILDPOINTERMFIELD_H_
40 #define _OSGCHILDPOINTERMFIELD_H_
46 #include "OSGConfig.h"
47 #include "OSGChildPointerMFieldBase.h"
51 // forward declarations
52 template <class PtrTypeT
, typename RefCountPolicy
, Int32 NamespaceI
>
53 class ChildPointerMField
;
55 template <class PtrTypeT
, typename RefCountPolicy
, Int32 NamespaceI
>
56 class ChildMFieldConstIterator
;
58 #ifndef OSG_CLEAN_FCFIELDS
59 template <class PtrTypeT
, typename RefCountPolicy
, Int32 NamespaceI
>
60 class ChildMFieldReferenceProxy
;
63 /*---------------------------------------------------------------------------*/
64 /* ChildMFieldIterator<PtrTypeT> */
65 /*---------------------------------------------------------------------------*/
67 /*! \ingroup GrpBaseFieldContainerFields
68 \ingroup GrpLibOSGBase
72 template <class PtrTypeT
, typename RefCountPolicy
, Int32 iNamespace
>
73 class ChildMFieldIterator
:
74 protected ChildPointerMField
<PtrTypeT
,
76 iNamespace
>::PtrStoreItType
78 template <class AccessHandlerT
, Int32 NamespaceI
>
79 friend class PointerMFieldCommon
;
81 template <class PT
, typename RC
, Int32 NI
>
82 friend class ChildPointerMField
;
84 template <class PT
, typename RC
, Int32 NI
>
85 friend class ChildMFieldConstIterator
;
87 template <class PT
, typename RC
, Int32 NI
>
88 friend typename ChildMFieldIterator
<PT
, RC
, NI
>::difference_type
89 operator-(ChildMFieldIterator
<PT
, RC
, NI
> const &lhs
,
90 ChildMFieldIterator
<PT
, RC
, NI
> const &rhs
);
92 template <class PT
, class RC
, Int32 NI
>
93 friend typename ChildMFieldConstIterator
<PT
, RC
, NI
>::difference_type
94 operator-(ChildMFieldIterator
<PT
, RC
, NI
> const &lhs
,
95 ChildMFieldConstIterator
<PT
, RC
, NI
> const &rhs
);
97 template <class PT
, class RC
, Int32 NI
>
98 friend typename ChildMFieldConstIterator
<PT
, RC
, NI
>::difference_type
99 operator-(ChildMFieldConstIterator
<PT
, RC
, NI
> const &lhs
,
100 ChildMFieldIterator
<PT
, RC
, NI
> const &rhs
);
102 /*========================== PUBLIC =================================*/
106 /*---------------------------------------------------------------------*/
107 /*! \name Public Types */
110 typedef ChildMFieldIterator Self
;
112 typedef ChildPointerMField
<PtrTypeT
,
114 iNamespace
> MFieldType
;
116 typedef typename
MFieldType::PtrStoreItType Inherited
;
118 typedef typename
MFieldType::AccessHandler AccessHandler
;
120 typedef PtrTypeT
const const_value
;
122 #ifndef OSG_CLEAN_FCFIELDS
123 typedef ChildMFieldReferenceProxy
<
126 iNamespace
> reference
;
130 typedef typename
MFieldType::PtrStoreType PtrStoreType
;
131 typedef typename
MFieldType::PtrStoreItType PtrStoreItType
;
133 typedef typename
MFieldType::const_iterator const_iterator
;
135 // std library typedefs
136 typedef typename
Inherited::iterator_category iterator_category
;
137 typedef typename
Inherited::difference_type difference_type
;
138 typedef PtrTypeT value_type
;
139 typedef PtrTypeT
* pointer
;
142 /*---------------------------------------------------------------------*/
143 /*! \name Constructors */
146 ChildMFieldIterator( void );
147 ChildMFieldIterator(const Self
&source
);
149 ChildMFieldIterator(const PtrStoreItType
&storeIter
,
150 MFieldType
*pField
);
153 /*---------------------------------------------------------------------*/
154 /*! \name Destructor */
157 ~ChildMFieldIterator(void);
160 /*---------------------------------------------------------------------*/
161 /*! \name Operators */
164 #ifndef OSG_CLEAN_FCFIELDS
165 reference
operator * ( void ) const;
166 reference
operator [](const difference_type offset
) const;
168 const_value
operator * ( void ) const;
169 const_value
operator [](const difference_type offset
) const;
173 /*---------------------------------------------------------------------*/
174 /*! \name Operators */
177 Self
&operator ++( void );
178 Self
operator ++( int );
180 Self
&operator --( void );
181 Self
operator --( int );
183 Self
&operator +=(const difference_type offset
);
184 Self
operator + (const difference_type offset
) const;
186 Self
&operator -=(const difference_type offset
);
187 Self
operator - (const difference_type offset
) const;
189 bool operator == (const Self
&rhs
) const;
190 bool operator != (const Self
&rhs
) const;
192 bool operator == (const const_iterator
&rhs
) const;
193 bool operator != (const const_iterator
&rhs
) const;
196 /*========================= PROTECTED ===============================*/
200 /*---------------------------------------------------------------------*/
204 const PtrStoreItType
&base(void) const;
207 /*========================== PRIVATE ================================*/
213 void operator =(const Self
&rhs
);
216 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
217 typename ChildMFieldIterator
<PtrTypeT
,
219 iNamespace
>::difference_type
220 operator-(ChildMFieldIterator
<PtrTypeT
,
222 iNamespace
> const &lhs
,
223 ChildMFieldIterator
<PtrTypeT
,
225 iNamespace
> const &rhs
);
227 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
228 ChildMFieldIterator
<PtrTypeT
, RefCountPolicyT
, iNamespace
>
230 typename ChildMFieldIterator
<PtrTypeT
,
232 iNamespace
>::differece_type
const offset
,
233 ChildMFieldIterator
<PtrTypeT
,
235 iNamespace
> const &rhs
);
237 /*---------------------------------------------------------------------------*/
238 /* ChildMFieldConstIterator<PtrTypeT> */
239 /*---------------------------------------------------------------------------*/
241 /*! \ingroup GrpBaseFieldContainerFields
242 \ingroup GrpLibOSGBase
246 template <class PtrTypeT
, typename RefCountPolicy
, Int32 iNamespace
>
247 class ChildMFieldConstIterator
:
248 protected ChildPointerMField
<PtrTypeT
,
250 iNamespace
>::PtrStoreConstItType
252 template <class AccessHandlerT
, Int32 NamespaceI
>
253 friend class PointerMFieldCommon
;
255 template <class PT
, typename RC
, Int32 NI
>
256 friend class ChildPointerMField
;
258 template <class PT
, typename RC
, Int32 NI
>
259 friend class ChildMFieldIterator
;
261 template <class PT
, class RC
, Int32 NI
>
262 friend typename ChildMFieldConstIterator
<PT
, RC
, NI
>::difference_type
263 operator-(ChildMFieldConstIterator
<PT
, RC
, NI
> const &lhs
,
264 ChildMFieldConstIterator
<PT
, RC
, NI
> const &rhs
);
266 template <class PT
, class RC
, Int32 NI
>
267 friend typename ChildMFieldConstIterator
<PT
, RC
, NI
>::difference_type
268 operator-(ChildMFieldIterator
<PT
, RC
, NI
> const &lhs
,
269 ChildMFieldConstIterator
<PT
, RC
, NI
> const &rhs
);
271 template <class PT
, class RC
, Int32 NI
>
272 friend typename ChildMFieldConstIterator
<PT
, RC
, NI
>::difference_type
273 operator-(ChildMFieldConstIterator
<PT
, RC
, NI
> const &lhs
,
274 ChildMFieldIterator
<PT
, RC
, NI
> const &rhs
);
276 /*========================== PUBLIC =================================*/
280 /*---------------------------------------------------------------------*/
281 /*! \name Public Types */
284 typedef ChildMFieldConstIterator Self
;
286 typedef ChildPointerMField
<PtrTypeT
,
288 iNamespace
> MFieldType
;
290 typedef typename
MFieldType::PtrStoreConstItType Inherited
;
292 typedef typename
MFieldType::AccessHandler AccessHandler
;
294 typedef PtrTypeT
const const_value
;
297 typedef typename
MFieldType::PtrStoreType PtrStoreType
;
298 typedef typename
MFieldType::PtrStoreConstItType PtrStoreConstItType
;
300 typedef typename
MFieldType::iterator iterator
;
303 typedef typename
Inherited::iterator_category iterator_category
;
304 typedef typename
Inherited::difference_type difference_type
;
305 typedef PtrTypeT value_type
;
306 typedef PtrTypeT
* pointer
;
309 /*---------------------------------------------------------------------*/
310 /*! \name Constructors */
313 ChildMFieldConstIterator( void );
314 ChildMFieldConstIterator(const Self
&source
);
315 ChildMFieldConstIterator(const iterator
&fieldIter
);
316 ChildMFieldConstIterator(const PtrStoreConstItType
&storeIter
);
319 /*---------------------------------------------------------------------*/
320 /*! \name Destructor */
323 ~ChildMFieldConstIterator(void);
326 /*---------------------------------------------------------------------*/
327 /*! \name Operators */
330 const_value
operator * (void ) const;
331 const_value
operator [](difference_type offset
) const;
334 /*---------------------------------------------------------------------*/
335 /*! \name Operators */
338 Self
&operator ++(void);
339 Self
operator ++(int );
341 Self
&operator --(void);
342 Self
operator --(int );
344 Self
&operator +=(const difference_type offset
);
345 Self
operator + (const difference_type offset
) const;
347 Self
&operator -=(const difference_type offset
);
348 Self
operator - (const difference_type offset
) const;
350 bool operator == (const Self
&rhs
) const;
351 bool operator != (const Self
&rhs
) const;
353 bool operator == (const iterator
&rhs
) const;
354 bool operator != (const iterator
&rhs
) const;
357 /*========================= PROTECTED ===============================*/
361 /*---------------------------------------------------------------------*/
365 PtrStoreConstItType
const &base(void) const;
368 /*========================== PRIVATE ================================*/
374 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
375 typename ChildMFieldConstIterator
<PtrTypeT
,
377 iNamespace
>::difference_type
378 operator-(ChildMFieldConstIterator
<PtrTypeT
,
380 iNamespace
> const &lhs
,
381 ChildMFieldConstIterator
<PtrTypeT
,
383 iNamespace
> const &rhs
);
385 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
386 typename ChildMFieldConstIterator
<PtrTypeT
,
388 iNamespace
>::difference_type
389 operator-(ChildMFieldIterator
<PtrTypeT
,
391 iNamespace
> const &lhs
,
392 ChildMFieldConstIterator
<PtrTypeT
,
394 iNamespace
> const &rhs
);
396 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
397 typename ChildMFieldConstIterator
<PtrTypeT
,
399 iNamespace
>::difference_type
400 operator-(ChildMFieldConstIterator
<PtrTypeT
,
402 iNamespace
> const &lhs
,
403 ChildMFieldIterator
<PtrTypeT
,
405 iNamespace
> const &rhs
);
407 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
408 ChildMFieldConstIterator
<PtrTypeT
, RefCountPolicyT
, iNamespace
>
410 typename ChildMFieldConstIterator
<PtrTypeT
,
412 iNamespace
>::difference_type
const offset
,
413 ChildMFieldConstIterator
<PtrTypeT
,
415 iNamespace
> const &rhs
);
417 /*-------------------------------------------------------------------------*/
418 /* ChildMFieldReferenceProxy<PtrTypeT> */
419 /*-------------------------------------------------------------------------*/
421 /*! \ingroup GrpBaseFieldContainerFields
422 \ingroup GrpLibOSGBase
426 template <class PtrTypeT
, typename RefCountPolicy
, Int32 iNamespace
>
427 class ChildMFieldReferenceProxy
429 /*========================== PUBLIC =================================*/
433 /*---------------------------------------------------------------------*/
434 /*! \name Public Types */
437 typedef ChildMFieldReferenceProxy Self
;
439 typedef ChildPointerMField
<PtrTypeT
,
441 iNamespace
> MFieldType
;
442 typedef typename
MFieldType::AccessHandler AccessHandler
;
445 typedef typename
MFieldType::StoredType StoredType
;
446 typedef typename
MFieldType::PtrStoreType PtrStoreType
;
447 typedef typename
MFieldType::PtrStoreItType PtrStoreItType
;
448 typedef typename
MFieldType::PtrStoreConstItType PtrStoreConstItType
;
451 typedef PtrTypeT
const const_value
;
454 /*---------------------------------------------------------------------*/
455 /*! \name Constructors */
458 ChildMFieldReferenceProxy(const PtrStoreItType
&storeIter
,
459 MFieldType
*pField
);
460 ChildMFieldReferenceProxy(const Self
&source
);
463 /*---------------------------------------------------------------------*/
464 /*! \name Destructor */
467 ~ChildMFieldReferenceProxy(void);
470 /*---------------------------------------------------------------------*/
471 /*! \name Operators */
474 operator const_value(void ) const;
475 const_value
operator-> (void ) const;
477 const Self
&operator = (const_value newValue
);
480 /*========================== PRIVATE ================================*/
484 PtrStoreItType _storeIter
;
488 /*---------------------------------------------------------------------------*/
489 /* ChildPointerMField<FieldConfigT> */
490 /*---------------------------------------------------------------------------*/
492 /*! \ingroup GrpBaseFieldContainerFields
493 \ingroup GrpLibOSGBase
496 template <class PtrTypeT
,
497 typename RefCountPolicy
,
498 Int32 NamespaceI
= 0>
499 class ChildPointerMField
:
500 public ChildPointerMFieldBase
<ChildAccessHandler
<RefCountPolicy
>,
504 /*========================== PUBLIC =================================*/
508 /*---------------------------------------------------------------------*/
509 /*! \name Public Types */
512 typedef ChildPointerMFieldBase
<
513 ChildAccessHandler
<RefCountPolicy
>,
514 NamespaceI
> Inherited
;
516 typedef ChildPointerMField Self
;
518 typedef PtrTypeT value_type
;
519 typedef PtrTypeT
const const_value
;
520 typedef value_type StoredType
;
522 typedef typename
Inherited::size_type size_type
;
523 typedef typename
Inherited::difference_type difference_type
;
525 typedef ChildMFieldIterator
<PtrTypeT
,
527 NamespaceI
> iterator
;
529 typedef ChildMFieldConstIterator
<PtrTypeT
,
531 NamespaceI
> const_iterator
;
533 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
534 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
536 typedef FieldTraits
<value_type
,
537 NamespaceI
> MFieldTraits
;
538 typedef FieldDescription
<
540 FieldType::MultiField
,
542 FieldType::ChildPtrField
> Description
;
544 #ifndef OSG_CLEAN_FCFIELDS
545 typedef ChildMFieldReferenceProxy
<PtrTypeT
,
547 NamespaceI
> reference
;
552 typedef EditFCPtrMFieldHandle
<Self
> EditHandle
;
553 typedef boost::shared_ptr
<EditHandle
> EditHandlePtr
;
555 typedef GetFCPtrMFieldHandle
<Self
> GetHandle
;
556 typedef boost::shared_ptr
<GetHandle
> GetHandlePtr
;
558 // handles for dynamic fields -- XXX TODO
559 // typedef EditPointerMFieldHandle<Self> DynamicEditHandle;
560 // typedef typename EditPointerMFieldHandle<Self>::Ptr DynamicEditHandlePtr;
562 // typedef GetPointerMFieldHandle <Self> DynamicGetHandle;
563 // typedef typename GetPointerMFieldHandle <Self>::Ptr DynamicGetHandlePtr;
566 /*---------------------------------------------------------------------*/
567 /*! \name Constants */
570 static FieldType::Cardinality
const fieldCard
= FieldType::MultiField
;
571 static FieldType::Class
const Class
= FieldType::ChildPtrField
;
574 /*---------------------------------------------------------------------*/
575 /*! \name Class Type */
578 static FieldType
const &getClassType(void);
581 /*---------------------------------------------------------------------*/
582 /*! \name Constructors */
585 ChildPointerMField(FieldContainer
* const pParent
,
586 UInt16 usChildFieldId
,
587 UInt16 usParentFieldId
);
591 /*---------------------------------------------------------------------*/
592 /*! \name Destructor */
595 ~ChildPointerMField(void);
598 /*---------------------------------------------------------------------*/
599 /*! \name String/Stream IO (Input) */
603 /*---------------------------------------------------------------------*/
607 #ifdef OSG_FIELD_TOCHECK
608 void setValues(const StorageType
&value
);
609 void setValues(const StorageTypeParent
&value
);
610 void setValues(const Self
&obj
);
614 /*---------------------------------------------------------------------*/
615 /*! \name Binary Interface */
618 void copyFromBin(BinaryDataHandler
&pMem
);
621 /*---------------------------------------------------------------------*/
622 /*! \name STL Interface */
625 iterator
begin_nc(void );
626 iterator
end_nc (void );
628 #ifndef OSG_CLEAN_FCFIELDS
629 reference
front_nc(void );
630 reference
back_nc (void );
633 iterator
find_nc (const_value value
);
636 /*---------------------------------------------------------------------*/
637 /*! \name Std Library Interface */
640 #ifndef OSG_CLEAN_FCFIELDS
641 iterator
begin (void );
642 iterator
end (void );
644 reverse_iterator
rbegin (void );
645 reverse_iterator
rend (void );
648 const_iterator
begin (void ) const;
649 const_iterator
end (void ) const;
651 const_reverse_iterator
rbegin (void ) const;
652 const_reverse_iterator
rend (void ) const;
654 #ifndef OSG_CLEAN_FCFIELDS
655 reference
front (void );
656 reference
back (void );
659 const_value
front (void ) const;
660 const_value
back (void ) const;
662 iterator
insert (iterator pos
,
664 void insert (iterator pos
,
667 template <class InputIteratorT
>
668 void insert (iterator pos
,
669 InputIteratorT first
,
670 InputIteratorT last
);
672 void erase (size_type index
);
673 #ifndef OSG_CLEAN_FCFIELDS
674 iterator
erase (iterator pos
);
676 iterator
erase (iterator first
,
680 #ifndef OSG_CLEAN_FCFIELDS
681 iterator
find (const_value value
);
683 const_iterator
find (const_value value
) const;
685 void push_back(const_value value
);
687 void resize (size_t newSize
,
688 const_value value
= NULL
);
690 void reserve (size_type newSize
);
695 void addValue (const_value value
);
698 void assign (size_type newSize
,
699 const_value value
= NULL
);
701 template <class InputIteratorT
>
702 void assign (InputIteratorT first
,
703 InputIteratorT last
);
705 void replace (size_type uiIdx
,
708 void replace (iterator pos
,
712 /*---------------------------------------------------------------------*/
713 /*! \name Index Operator */
716 #ifndef OSG_CLEAN_FCFIELDS
717 reference
operator [](const size_type index
);
719 const_value
operator [](const size_type index
) const;
722 /*---------------------------------------------------------------------*/
723 /*! \name Assignment */
726 #ifdef OSG_FIELD_TOCHECK
727 const Self
& operator =(const Self
&source
);
731 /*---------------------------------------------------------------------*/
735 #ifdef OSG_MT_CPTR_ASPECT
736 void syncWith(Self
&source
,
737 ConstFieldMaskArg syncMode
,
739 AspectOffsetStore
&oOffsets
);
743 /*========================= PROTECTED ===============================*/
747 /*---------------------------------------------------------------------*/
751 static FieldType _fieldType
;
754 /*========================== PRIVATE ================================*/
758 ChildPointerMField(const Self
&other
);
763 #include "OSGChildPointerMField.inl"
765 #endif // _OSGCHILDPOINTERMFIELD_H_