changed: gcc8 base update
[opensg.git] / Source / Base / FieldContainer / Fields / PointerFields / OSGChildPointerMField.h
blob5e553036beb195885c1bd027eed18f29b202efc7
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2008 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 #ifndef _OSGCHILDPOINTERMFIELD_H_
40 #define _OSGCHILDPOINTERMFIELD_H_
42 #ifdef __sgi
43 #pragma once
44 #endif
46 #include "OSGConfig.h"
47 #include "OSGChildPointerMFieldBase.h"
49 OSG_BEGIN_NAMESPACE
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;
61 #endif
63 /*---------------------------------------------------------------------------*/
64 /* ChildMFieldIterator<PtrTypeT> */
65 /*---------------------------------------------------------------------------*/
67 /*! \ingroup GrpBaseFieldContainerFields
68 \ingroup GrpLibOSGBase
69 \nohierarchy
72 template <class PtrTypeT, typename RefCountPolicy, Int32 iNamespace>
73 class ChildMFieldIterator :
74 protected ChildPointerMField<PtrTypeT,
75 RefCountPolicy,
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 =================================*/
104 public:
106 /*---------------------------------------------------------------------*/
107 /*! \name Public Types */
108 /*! \{ */
110 typedef ChildMFieldIterator Self;
112 typedef ChildPointerMField<PtrTypeT,
113 RefCountPolicy,
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<
124 PtrTypeT,
125 RefCountPolicy,
126 iNamespace > reference;
127 #endif
129 // store types
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;
141 /*! \} */
142 /*---------------------------------------------------------------------*/
143 /*! \name Constructors */
144 /*! \{ */
146 ChildMFieldIterator( void );
147 ChildMFieldIterator(const Self &source );
149 ChildMFieldIterator(const PtrStoreItType &storeIter,
150 MFieldType *pField );
152 /*! \} */
153 /*---------------------------------------------------------------------*/
154 /*! \name Destructor */
155 /*! \{ */
157 ~ChildMFieldIterator(void);
159 /*! \} */
160 /*---------------------------------------------------------------------*/
161 /*! \name Operators */
162 /*! \{ */
164 #ifndef OSG_CLEAN_FCFIELDS
165 reference operator * ( void ) const;
166 reference operator [](const difference_type offset) const;
167 #else
168 const_value operator * ( void ) const;
169 const_value operator [](const difference_type offset) const;
170 #endif
172 /*! \} */
173 /*---------------------------------------------------------------------*/
174 /*! \name Operators */
175 /*! \{ */
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;
195 /*! \} */
196 /*========================= PROTECTED ===============================*/
198 protected:
200 /*---------------------------------------------------------------------*/
201 /*! \name Base */
202 /*! \{ */
204 const PtrStoreItType &base(void) const;
206 /*! \} */
207 /*========================== PRIVATE ================================*/
209 private:
211 MFieldType *_pField;
213 void operator =(const Self &rhs);
216 template <class PtrTypeT, class RefCountPolicyT, Int32 iNamespace>
217 typename ChildMFieldIterator<PtrTypeT,
218 RefCountPolicyT,
219 iNamespace >::difference_type
220 operator-(ChildMFieldIterator<PtrTypeT,
221 RefCountPolicyT,
222 iNamespace > const &lhs,
223 ChildMFieldIterator<PtrTypeT,
224 RefCountPolicyT,
225 iNamespace > const &rhs );
227 template <class PtrTypeT, class RefCountPolicyT, Int32 iNamespace>
228 ChildMFieldIterator<PtrTypeT, RefCountPolicyT, iNamespace>
229 operator+(
230 typename ChildMFieldIterator<PtrTypeT,
231 RefCountPolicyT,
232 iNamespace >::differece_type const offset,
233 ChildMFieldIterator<PtrTypeT,
234 RefCountPolicyT,
235 iNamespace > const &rhs );
237 /*---------------------------------------------------------------------------*/
238 /* ChildMFieldConstIterator<PtrTypeT> */
239 /*---------------------------------------------------------------------------*/
241 /*! \ingroup GrpBaseFieldContainerFields
242 \ingroup GrpLibOSGBase
243 \nohierarchy
246 template <class PtrTypeT, typename RefCountPolicy, Int32 iNamespace>
247 class ChildMFieldConstIterator :
248 protected ChildPointerMField<PtrTypeT,
249 RefCountPolicy,
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 =================================*/
278 public:
280 /*---------------------------------------------------------------------*/
281 /*! \name Public Types */
282 /*! \{ */
284 typedef ChildMFieldConstIterator Self;
286 typedef ChildPointerMField<PtrTypeT,
287 RefCountPolicy,
288 iNamespace > MFieldType;
290 typedef typename MFieldType::PtrStoreConstItType Inherited;
292 typedef typename MFieldType::AccessHandler AccessHandler;
294 typedef PtrTypeT const const_value;
296 // store types
297 typedef typename MFieldType::PtrStoreType PtrStoreType;
298 typedef typename MFieldType::PtrStoreConstItType PtrStoreConstItType;
300 typedef typename MFieldType::iterator iterator;
302 // std library types
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;
308 /*! \} */
309 /*---------------------------------------------------------------------*/
310 /*! \name Constructors */
311 /*! \{ */
313 ChildMFieldConstIterator( void );
314 ChildMFieldConstIterator(const Self &source );
315 ChildMFieldConstIterator(const iterator &fieldIter);
316 ChildMFieldConstIterator(const PtrStoreConstItType &storeIter);
318 /*! \} */
319 /*---------------------------------------------------------------------*/
320 /*! \name Destructor */
321 /*! \{ */
323 ~ChildMFieldConstIterator(void);
325 /*! \} */
326 /*---------------------------------------------------------------------*/
327 /*! \name Operators */
328 /*! \{ */
330 const_value operator * (void ) const;
331 const_value operator [](difference_type offset) const;
333 /*! \} */
334 /*---------------------------------------------------------------------*/
335 /*! \name Operators */
336 /*! \{ */
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;
356 /*! \} */
357 /*========================= PROTECTED ===============================*/
359 protected:
361 /*---------------------------------------------------------------------*/
362 /*! \name Base */
363 /*! \{ */
365 PtrStoreConstItType const &base(void) const;
367 /*! \} */
368 /*========================== PRIVATE ================================*/
370 private:
374 template <class PtrTypeT, class RefCountPolicyT, Int32 iNamespace>
375 typename ChildMFieldConstIterator<PtrTypeT,
376 RefCountPolicyT,
377 iNamespace >::difference_type
378 operator-(ChildMFieldConstIterator<PtrTypeT,
379 RefCountPolicyT,
380 iNamespace > const &lhs,
381 ChildMFieldConstIterator<PtrTypeT,
382 RefCountPolicyT,
383 iNamespace > const &rhs );
385 template <class PtrTypeT, class RefCountPolicyT, Int32 iNamespace>
386 typename ChildMFieldConstIterator<PtrTypeT,
387 RefCountPolicyT,
388 iNamespace >::difference_type
389 operator-(ChildMFieldIterator <PtrTypeT,
390 RefCountPolicyT,
391 iNamespace > const &lhs,
392 ChildMFieldConstIterator<PtrTypeT,
393 RefCountPolicyT,
394 iNamespace > const &rhs );
396 template <class PtrTypeT, class RefCountPolicyT, Int32 iNamespace>
397 typename ChildMFieldConstIterator<PtrTypeT,
398 RefCountPolicyT,
399 iNamespace >::difference_type
400 operator-(ChildMFieldConstIterator<PtrTypeT,
401 RefCountPolicyT,
402 iNamespace > const &lhs,
403 ChildMFieldIterator <PtrTypeT,
404 RefCountPolicyT,
405 iNamespace > const &rhs );
407 template <class PtrTypeT, class RefCountPolicyT, Int32 iNamespace>
408 ChildMFieldConstIterator<PtrTypeT, RefCountPolicyT, iNamespace>
409 operator+(
410 typename ChildMFieldConstIterator<PtrTypeT,
411 RefCountPolicyT,
412 iNamespace >::difference_type const offset,
413 ChildMFieldConstIterator<PtrTypeT,
414 RefCountPolicyT,
415 iNamespace > const &rhs );
417 /*-------------------------------------------------------------------------*/
418 /* ChildMFieldReferenceProxy<PtrTypeT> */
419 /*-------------------------------------------------------------------------*/
421 /*! \ingroup GrpBaseFieldContainerFields
422 \ingroup GrpLibOSGBase
423 \nohierarchy
426 template <class PtrTypeT, typename RefCountPolicy, Int32 iNamespace>
427 class ChildMFieldReferenceProxy
429 /*========================== PUBLIC =================================*/
431 public:
433 /*---------------------------------------------------------------------*/
434 /*! \name Public Types */
435 /*! \{ */
437 typedef ChildMFieldReferenceProxy Self;
439 typedef ChildPointerMField<PtrTypeT,
440 RefCountPolicy,
441 iNamespace > MFieldType;
442 typedef typename MFieldType::AccessHandler AccessHandler;
444 // store types
445 typedef typename MFieldType::StoredType StoredType;
446 typedef typename MFieldType::PtrStoreType PtrStoreType;
447 typedef typename MFieldType::PtrStoreItType PtrStoreItType;
448 typedef typename MFieldType::PtrStoreConstItType PtrStoreConstItType;
450 // std library types
451 typedef PtrTypeT const const_value;
453 /*! \} */
454 /*---------------------------------------------------------------------*/
455 /*! \name Constructors */
456 /*! \{ */
458 ChildMFieldReferenceProxy(const PtrStoreItType &storeIter,
459 MFieldType *pField );
460 ChildMFieldReferenceProxy(const Self &source );
462 /*! \} */
463 /*---------------------------------------------------------------------*/
464 /*! \name Destructor */
465 /*! \{ */
467 ~ChildMFieldReferenceProxy(void);
469 /*! \} */
470 /*---------------------------------------------------------------------*/
471 /*! \name Operators */
472 /*! \{ */
474 operator const_value(void ) const;
475 const_value operator-> (void ) const;
477 const Self &operator = (const_value newValue);
479 /*! \} */
480 /*========================== PRIVATE ================================*/
482 private:
484 PtrStoreItType _storeIter;
485 MFieldType *_pField;
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>,
501 NamespaceI >
504 /*========================== PUBLIC =================================*/
506 public:
508 /*---------------------------------------------------------------------*/
509 /*! \name Public Types */
510 /*! \{ */
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,
526 RefCountPolicy,
527 NamespaceI > iterator;
529 typedef ChildMFieldConstIterator <PtrTypeT,
530 RefCountPolicy,
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<
539 MFieldTraits,
540 FieldType::MultiField,
541 RefCountPolicy,
542 FieldType::ChildPtrField > Description;
544 #ifndef OSG_CLEAN_FCFIELDS
545 typedef ChildMFieldReferenceProxy<PtrTypeT,
546 RefCountPolicy,
547 NamespaceI > reference;
548 #endif
551 // handles
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;
565 /*! \} */
566 /*---------------------------------------------------------------------*/
567 /*! \name Constants */
568 /*! \{ */
570 static FieldType::Cardinality const fieldCard = FieldType::MultiField;
571 static FieldType::Class const Class = FieldType::ChildPtrField;
573 /*! \} */
574 /*---------------------------------------------------------------------*/
575 /*! \name Class Type */
576 /*! \{ */
578 static FieldType const &getClassType(void);
580 /*! \} */
581 /*---------------------------------------------------------------------*/
582 /*! \name Constructors */
583 /*! \{ */
585 ChildPointerMField(FieldContainer * const pParent,
586 UInt16 usChildFieldId,
587 UInt16 usParentFieldId);
590 /*! \} */
591 /*---------------------------------------------------------------------*/
592 /*! \name Destructor */
593 /*! \{ */
595 ~ChildPointerMField(void);
597 /*! \} */
598 /*---------------------------------------------------------------------*/
599 /*! \name String/Stream IO (Input) */
600 /*! \{ */
602 /*! \} */
603 /*---------------------------------------------------------------------*/
604 /*! \name Set */
605 /*! \{ */
607 #ifdef OSG_FIELD_TOCHECK
608 void setValues(const StorageType &value);
609 void setValues(const StorageTypeParent &value);
610 void setValues(const Self &obj );
611 #endif
613 /*! \} */
614 /*---------------------------------------------------------------------*/
615 /*! \name Binary Interface */
616 /*! \{ */
618 void copyFromBin(BinaryDataHandler &pMem);
620 /*! \} */
621 /*---------------------------------------------------------------------*/
622 /*! \name STL Interface */
623 /*! \{ */
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 );
631 #endif
633 iterator find_nc (const_value value);
635 /*! \} */
636 /*---------------------------------------------------------------------*/
637 /*! \name Std Library Interface */
638 /*! \{ */
640 #ifndef OSG_CLEAN_FCFIELDS
641 iterator begin (void );
642 iterator end (void );
644 reverse_iterator rbegin (void );
645 reverse_iterator rend (void );
646 #endif
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 );
657 #endif
659 const_value front (void ) const;
660 const_value back (void ) const;
662 iterator insert (iterator pos,
663 const_value value );
664 void insert (iterator pos,
665 size_type n,
666 const_value value );
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,
677 iterator last );
678 #endif
680 #ifndef OSG_CLEAN_FCFIELDS
681 iterator find (const_value value );
682 #endif
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 );
692 void clear (void );
694 #ifdef OSG_1_COMPAT
695 void addValue (const_value value );
696 #endif
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,
706 const_value value );
708 void replace (iterator pos,
709 const_value value );
711 /*! \} */
712 /*---------------------------------------------------------------------*/
713 /*! \name Index Operator */
714 /*! \{ */
716 #ifndef OSG_CLEAN_FCFIELDS
717 reference operator [](const size_type index);
718 #endif
719 const_value operator [](const size_type index) const;
721 /*! \} */
722 /*---------------------------------------------------------------------*/
723 /*! \name Assignment */
724 /*! \{ */
726 #ifdef OSG_FIELD_TOCHECK
727 const Self & operator =(const Self &source);
728 #endif
730 /*! \} */
731 /*---------------------------------------------------------------------*/
732 /*! \name MT Sync */
733 /*! \{ */
735 #ifdef OSG_MT_CPTR_ASPECT
736 void syncWith(Self &source,
737 ConstFieldMaskArg syncMode,
738 UInt32 uiSyncInfo,
739 AspectOffsetStore &oOffsets );
740 #endif
742 /*! \} */
743 /*========================= PROTECTED ===============================*/
745 protected:
747 /*---------------------------------------------------------------------*/
748 /*! \name Members */
749 /*! \{ */
751 static FieldType _fieldType;
753 /*! \} */
754 /*========================== PRIVATE ================================*/
756 private:
758 ChildPointerMField(const Self &other);
761 OSG_END_NAMESPACE
763 #include "OSGChildPointerMField.inl"
765 #endif // _OSGCHILDPOINTERMFIELD_H_