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 _OSGPOINTERMFIELD_H_
40 #define _OSGPOINTERMFIELD_H_
46 #include "OSGPointerMFieldCommon.h"
47 #include "OSGPointerAccessHandler.h"
51 // forward declarations
52 template <class PtrTypeT
,
53 typename RefCountPolicy
,
57 #ifndef OSG_CLEAN_FCFIELDS
58 template <class PtrTypeT
,
59 typename RefCountPolicy
,
61 class PointerMFieldReferenceProxy
;
64 template <class PtrTypeT
,
65 typename RefCountPolicy
,
67 class PointerMFieldConstIterator
;
69 /*---------------------------------------------------------------------------*/
70 /* PointerMFieldIterator<PtrTypeT> */
71 /*---------------------------------------------------------------------------*/
73 /*! \ingroup GrpBaseFieldContainerFields
74 \ingroup GrpLibOSGBase
78 template <class PtrTypeT
, typename RefCountPolicy
, Int32 NamespaceI
>
79 class PointerMFieldIterator
:
80 protected PointerMField
<PtrTypeT
,
82 NamespaceI
>::PtrStoreItType
84 /*========================== PUBLIC =================================*/
88 /*---------------------------------------------------------------------*/
89 /*! \name Public Types */
92 typedef PointerMFieldIterator Self
;
94 typedef PointerMField
<PtrTypeT
,
96 NamespaceI
> MFieldType
;
98 typedef typename
MFieldType::PtrStoreItType Inherited
;
100 typedef typename
MFieldType::AccessHandler AccessHandler
;
102 typedef PtrTypeT
const const_value
;
105 typedef typename
MFieldType::StoredType StoredType
;
106 typedef typename
MFieldType::PtrStoreType PtrStoreType
;
107 typedef typename
MFieldType::PtrStoreItType PtrStoreItType
;
109 typedef typename
MFieldType::const_iterator const_iterator
;
111 // std library typedefs
113 typedef typename
Inherited::iterator_category iterator_category
;
114 typedef typename
Inherited::difference_type difference_type
;
115 typedef PtrTypeT value_type
;
116 typedef PtrTypeT
* pointer
;
118 #ifndef OSG_CLEAN_FCFIELDS
119 typedef PointerMFieldReferenceProxy
<
122 NamespaceI
> reference
;
124 typedef typename
Inherited::reference reference
;
127 #if defined(WIN32) && _SECURE_SCL == 1 && _MSC_VER < 1600
128 typedef typename
Inherited::_Checked_iterator_base_type
129 _Checked_iterator_base_type
;
133 /*---------------------------------------------------------------------*/
134 /*! \name Constructors */
137 PointerMFieldIterator( void );
138 PointerMFieldIterator(const Self
&source
);
140 PointerMFieldIterator(const PtrStoreItType
&storeIter
,
141 MFieldType
*pField
);
144 /*---------------------------------------------------------------------*/
145 /*! \name Destructor */
148 ~PointerMFieldIterator(void);
151 /*---------------------------------------------------------------------*/
152 /*! \name Operators */
155 #ifndef OSG_CLEAN_FCFIELDS
156 reference
operator *( void ) const;
157 reference
operator [](const difference_type offset
) const;
159 const_value
operator *( void ) const;
160 const_value
operator [](const difference_type offset
) const;
164 /*---------------------------------------------------------------------*/
165 /*! \name Operators */
168 Self
&operator ++( void );
169 Self
operator ++( int );
171 Self
&operator --( void );
172 Self
operator --( int );
174 Self
&operator +=(const difference_type offset
);
175 Self
operator + (const difference_type offset
) const;
177 Self
&operator -=(const difference_type offset
);
178 Self
operator - (const difference_type offset
) const;
181 bool operator == (const Self
&rhs
) const;
182 bool operator != (const Self
&rhs
) const;
184 bool operator == (const const_iterator
&rhs
) const;
185 bool operator != (const const_iterator
&rhs
) const;
188 /*---------------------------------------------------------------------*/
189 /*! \name Operators */
192 const Self
&operator =(const Self
&other
);
195 /*---------------------------------------------------------------------*/
199 const PtrStoreItType
&base(void) const;
202 /*========================= PROTECTED ===============================*/
206 /*========================== PRIVATE ================================*/
212 template <class AccessHandlerT
, Int32 NI
>
213 friend class PointerMFieldCommon
;
215 template <class PT
, typename RC
, Int32 NI
>
216 friend class PointerMFieldConstIterator
;
218 template <class PT
, typename RC
, Int32 NI
>
219 friend class PointerMField
;
223 template <class PtrTypeT
, class RefCountPolicyT
, Int32 NamespaceI
>
224 typename PointerMFieldIterator
<PtrTypeT
,
226 NamespaceI
>::difference_type
227 operator-(PointerMFieldIterator
<PtrTypeT
,
229 NamespaceI
> const &lhs
,
231 PointerMFieldIterator
<PtrTypeT
,
233 NamespaceI
> const &rhs
);
235 template <class PtrTypeT
, class RefCountPolicyT
, Int32 NamespaceI
>
236 PointerMFieldIterator
<PtrTypeT
,
241 typename PointerMFieldIterator
<
244 NamespaceI
>::differece_type
const offset
,
246 PointerMFieldIterator
<
249 NamespaceI
> const &rhs
);
252 /*---------------------------------------------------------------------------*/
253 /* PointerMFieldConstIterator<PtrTypeT> */
254 /*---------------------------------------------------------------------------*/
256 /*! \ingroup GrpBaseFieldContainerFields
257 \ingroup GrpLibOSGBase
261 template <class PtrTypeT
, typename RefCountPolicy
, Int32 NamespaceI
>
262 class PointerMFieldConstIterator
:
263 protected PointerMField
<PtrTypeT
,
265 NamespaceI
>::PtrStoreConstItType
267 /*========================== PUBLIC =================================*/
271 /*---------------------------------------------------------------------*/
272 /*! \name Public Types */
275 typedef PointerMFieldConstIterator Self
;
277 typedef PointerMField
<PtrTypeT
,
279 NamespaceI
> MFieldType
;
281 typedef typename
MFieldType::PtrStoreConstItType Inherited
;
283 typedef typename
MFieldType::AccessHandler AccessHandler
;
285 typedef PtrTypeT
const const_value
;
288 typedef typename
MFieldType::StoredType StoredType
;
289 typedef typename
MFieldType::PtrStoreType PtrStoreType
;
290 typedef typename
MFieldType::PtrStoreConstItType PtrStoreConstItType
;
292 typedef typename
MFieldType::iterator iterator
;
295 typedef typename
Inherited::iterator_category iterator_category
;
296 typedef typename
Inherited::difference_type difference_type
;
297 typedef typename
Inherited::value_type value_type
;
298 typedef typename
Inherited::pointer pointer
;
299 typedef typename
Inherited::reference reference
;
302 /*---------------------------------------------------------------------*/
303 /*! \name Constructors */
306 PointerMFieldConstIterator( void );
307 PointerMFieldConstIterator(const Self
&source
);
308 PointerMFieldConstIterator(const iterator
&fieldIter
);
309 explicit PointerMFieldConstIterator(const PtrStoreConstItType
&storeIter
);
312 /*---------------------------------------------------------------------*/
313 /*! \name Destructor */
316 ~PointerMFieldConstIterator(void);
319 /*---------------------------------------------------------------------*/
320 /*! \name Operators */
323 const_value
operator * ( void ) const;
324 const_value
operator [](const difference_type offset
) const;
327 /*---------------------------------------------------------------------*/
328 /*! \name Operators */
331 Self
&operator ++( void );
332 Self
operator ++( int );
334 Self
&operator --( void );
335 Self
operator --( int );
337 Self
&operator +=(const difference_type offset
);
338 Self
operator + (const difference_type offset
) const;
340 Self
&operator -=(const difference_type offset
);
341 Self
operator - (const difference_type offset
) const;
344 bool operator == (const Self
&rhs
) const;
345 bool operator != (const Self
&rhs
) const;
347 bool operator == (const iterator
&rhs
) const;
348 bool operator != (const iterator
&rhs
) const;
351 /*---------------------------------------------------------------------*/
355 const PtrStoreConstItType
&base(void) const;
358 /*========================= PROTECTED ===============================*/
362 /*========================== PRIVATE ================================*/
366 template <class AccessHandlerT
, Int32 NI
>
367 friend class PointerMFieldCommon
;
369 template <class PT
, typename RC
, Int32 NI
>
370 friend class PointerMFieldIterator
;
372 template <class PT
, typename RC
, Int32 NI
>
373 friend class PointerMField
;
376 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
377 typename PointerMFieldConstIterator
<PtrTypeT
,
379 iNamespace
>::difference_type
380 operator-(PointerMFieldConstIterator
<PtrTypeT
,
382 iNamespace
> const &lhs
,
383 PointerMFieldConstIterator
<PtrTypeT
,
385 iNamespace
> const &rhs
);
387 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
388 typename PointerMFieldConstIterator
<PtrTypeT
,
390 iNamespace
>::difference_type
391 operator-(PointerMFieldIterator
<PtrTypeT
,
393 iNamespace
> const &lhs
,
394 PointerMFieldConstIterator
<PtrTypeT
,
396 iNamespace
> const &rhs
);
398 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
399 typename PointerMFieldConstIterator
<PtrTypeT
,
401 iNamespace
>::difference_type
402 operator-(PointerMFieldConstIterator
<PtrTypeT
,
404 iNamespace
> const &lhs
,
405 PointerMFieldIterator
<PtrTypeT
,
407 iNamespace
> const &rhs
);
409 template <class PtrTypeT
, class RefCountPolicyT
, Int32 iNamespace
>
410 PointerMFieldConstIterator
<PtrTypeT
, RefCountPolicyT
, iNamespace
>
412 typename PointerMFieldConstIterator
<
415 iNamespace
>::difference_type
const offset
,
417 PointerMFieldConstIterator
<
420 iNamespace
> const &rhs
);
423 #ifndef OSG_CLEAN_FCFIELDS
424 /*-------------------------------------------------------------------------*/
425 /* WeakMFieldReferenceProxy<PtrTypeT> */
426 /*-------------------------------------------------------------------------*/
428 /*! \ingroup GrpBaseFieldContainerFields
429 \ingroup GrpLibOSGBase
433 template <class PtrTypeT
, typename RefCountPolicy
, Int32 NamespaceI
>
434 class PointerMFieldReferenceProxy
436 /*========================== PUBLIC =================================*/
440 /*---------------------------------------------------------------------*/
441 /*! \name Public Types */
444 typedef PointerMFieldReferenceProxy Self
;
446 typedef PointerMField
<PtrTypeT
,
448 NamespaceI
> MFieldType
;
450 typedef typename
MFieldType::AccessHandler AccessHandler
;
453 typedef typename
MFieldType::StoredType StoredType
;
454 typedef typename
MFieldType::PtrStoreType PtrStoreType
;
455 typedef typename
MFieldType::PtrStoreItType PtrStoreItType
;
456 typedef typename
MFieldType::PtrStoreConstItType PtrStoreConstItType
;
459 typedef PtrTypeT value_type
;
462 /*---------------------------------------------------------------------*/
463 /*! \name Constructors */
466 PointerMFieldReferenceProxy(const PtrStoreItType
&storeIter
,
467 MFieldType
*pField
);
469 PointerMFieldReferenceProxy(const Self
&source
);
472 /*---------------------------------------------------------------------*/
473 /*! \name Destructor */
476 ~PointerMFieldReferenceProxy(void);
479 /*---------------------------------------------------------------------*/
480 /*! \name Operators */
483 operator value_type(void) const;
484 value_type
operator-> (void) const;
486 void operator=(value_type newValue
);
489 /*========================== PRIVATE ================================*/
493 PtrStoreItType _storeIter
;
498 /*---------------------------------------------------------------------------*/
499 /* WeakPointerMField<FieldConfigT> */
500 /*---------------------------------------------------------------------------*/
502 /*! \ingroup GrpBaseFieldContainerFields
503 \ingroup GrpLibOSGBase
506 template <class PtrTypeT
,
507 typename RefCountPolicy
,
508 Int32 NamespaceI
= 0>
509 class PointerMField
:
510 public PointerMFieldCommon
<PointerAccessHandler
<RefCountPolicy
>,
513 /*========================== PUBLIC =================================*/
517 /*---------------------------------------------------------------------*/
518 /*! \name Public Types */
521 typedef PointerMFieldCommon
<
522 PointerAccessHandler
<RefCountPolicy
>,
523 NamespaceI
> Inherited
;
525 typedef PointerMField Self
;
527 typedef PtrTypeT
const const_value
;
528 typedef PtrTypeT value_type
;
529 typedef value_type StoredType
;
531 typedef typename
Inherited::size_type size_type
;
532 typedef typename
Inherited::difference_type difference_type
;
534 typedef PointerMFieldIterator
<PtrTypeT
,
536 NamespaceI
> iterator
;
538 typedef PointerMFieldConstIterator
<PtrTypeT
,
540 NamespaceI
> const_iterator
;
542 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
543 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
546 typedef FieldTraits
<value_type
,
547 NamespaceI
> MFieldTraits
;
548 typedef FieldDescription
<
550 FieldType::MultiField
,
552 FieldType::PtrField
> Description
;
554 #ifndef OSG_CLEAN_FCFIELDS
555 typedef PointerMFieldReferenceProxy
<PtrTypeT
,
557 NamespaceI
> reference
;
561 typedef EditFCPtrMFieldHandle
<Self
> EditHandle
;
562 typedef boost::shared_ptr
<EditHandle
> EditHandlePtr
;
564 typedef GetFCPtrMFieldHandle
<Self
> GetHandle
;
565 typedef boost::shared_ptr
<GetHandle
> GetHandlePtr
;
567 // handles for dynamic fields -- XXX TODO
568 // typedef EditPointerMFieldHandle<Self> DynamicEditHandle;
569 // typedef typename EditPointerMFieldHandle<Self>::Ptr DynamicEditHandlePtr;
571 // typedef GetPointerMFieldHandle <Self> DynamicGetHandle;
572 // typedef typename GetPointerMFieldHandle <Self>::Ptr DynamicGetHandlePtr;
575 /*---------------------------------------------------------------------*/
576 /*! \name Constants */
579 static FieldType::Cardinality
const fieldCard
= FieldType::MultiField
;
580 static FieldType::Class
const Class
= FieldType::PtrField
;
583 /*---------------------------------------------------------------------*/
584 /*! \name Class Type */
587 static FieldType
const &getClassType(void);
590 /*---------------------------------------------------------------------*/
591 /*! \name Constructors */
594 PointerMField( void );
595 PointerMField(const Self
&other
);
596 explicit PointerMField(const UInt32 initSize
);
599 /*---------------------------------------------------------------------*/
600 /*! \name Destructor */
603 ~PointerMField(void);
606 /*---------------------------------------------------------------------*/
607 /*! \name String/Stream IO (Input) */
611 /*---------------------------------------------------------------------*/
615 #ifdef OSG_FIELD_TOCHECK
616 void setValues(const StorageType
&value
);
617 void setValues(const StorageTypeParent
&value
);
618 void setValues(const Self
&obj
);
622 /*---------------------------------------------------------------------*/
623 /*! \name Binary Interface */
626 void copyFromBin(BinaryDataHandler
&pMem
);
629 /*---------------------------------------------------------------------*/
630 /*! \name STL Interface */
633 iterator
begin_nc(void );
634 iterator
end_nc (void );
636 #ifndef OSG_CLEAN_FCFIELDS
637 reference
front_nc(void );
638 reference
back_nc (void );
641 iterator
find_nc (const_value value
);
644 /*---------------------------------------------------------------------*/
645 /*! \name Std Library Interface */
648 #ifndef OSG_CLEAN_FCFIELDS
649 iterator
begin (void );
650 iterator
end (void );
652 reverse_iterator
rbegin (void );
653 reverse_iterator
rend (void );
656 const_iterator
begin (void ) const;
657 const_iterator
end (void ) const;
659 const_reverse_iterator
rbegin (void ) const;
660 const_reverse_iterator
rend (void ) const;
662 #ifndef OSG_CLEAN_FCFIELDS
663 reference
front (void );
664 reference
back (void );
667 const_value
front (void ) const;
668 const_value
back (void ) const;
670 iterator
insert (iterator pos
,
673 void insert (iterator pos
,
677 template <class InputIteratorT
>
678 void insert (iterator pos
,
679 InputIteratorT first
,
680 InputIteratorT last
);
682 void erase (size_type index
);
683 #ifndef OSG_CLEAN_FCFIELDS
684 iterator
erase (iterator pos
);
685 iterator
erase (iterator first
,
689 #ifndef OSG_CLEAN_FCFIELDS
690 iterator
find (const_value value
);
692 const_iterator
find (const_value value
) const;
694 void push_back(const_value value
);
696 void resize (size_t newSize
,
697 const_value value
= NULL
);
699 void reserve (size_type newSize
);
704 void addValue (const_value value
);
707 void assign (size_type newSize
,
708 const_value value
= NULL
);
710 template <class InputIteratorT
>
711 void assign (InputIteratorT first
,
712 InputIteratorT last
);
714 void replace (UInt32 uiIdx
,
717 void replace (iterator pos
,
721 /*---------------------------------------------------------------------*/
722 /*! \name Index Operator */
725 #ifndef OSG_CLEAN_FCFIELDS
726 reference
operator [](size_type
const index
);
728 const_value
operator [](size_type
const index
) const;
731 /*---------------------------------------------------------------------*/
735 bool operator ==(const Self
&source
) const;
738 /*---------------------------------------------------------------------*/
739 /*! \name Assignment */
742 Self
&operator =(Self
const &source
);
745 /*---------------------------------------------------------------------*/
749 #ifdef OSG_MT_CPTR_ASPECT
750 void syncWith(Self
&source
,
751 ConstFieldMaskArg syncMode
,
753 AspectOffsetStore
&oOffsets
);
757 /*========================= PROTECTED ===============================*/
761 /*---------------------------------------------------------------------*/
765 static FieldType _fieldType
;
768 /*---------------------------------------------------------------------*/
769 /*! \name FieldDesc creation */
772 static FieldDescriptionBase
*
773 createFieldDescription (const Char8
*szFieldname
,
775 FieldEditMethod fEditMethod
,
776 FieldGetMethod fGetMethod
);
778 static FieldDescriptionBase
*
779 createIdxFieldDescription(const Char8
*szFieldname
,
781 FieldIndexEditMethod fEditMethod
,
782 FieldIndexGetMethod fGetMethod
);
785 /*========================== PRIVATE ================================*/
792 #include "OSGPointerMField.inl"
794 #endif // _OSGPOINTERMFIELD_H_