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 _OSGCHILDACCESSHANDLER_H_
40 #define _OSGCHILDACCESSHANDLER_H_
46 #include "OSGConfig.h"
50 // forward declarations
51 class PointerMFieldBase
;
53 class PointerSFieldBase
;
55 template <typename AccessHandlerT
, Int32 NamespaceI
>
56 class ChildPointerMFieldBase
;
58 template <typename AccessHandlerT
, Int32 NamespaceI
>
59 class ChildPointerSFieldBase
;
61 /*! \ingroup GrpBaseFieldContainerFields
62 \ingroup GrpLibOSGBase
66 template<typename RefCountPolicyT
>
67 class ChildAccessHandler
69 /*========================== PUBLIC =================================*/
73 /*---------------------------------------------------------------------*/
74 /*! \name Public Types */
77 typedef ChildAccessHandler Self
;
79 typedef RefCountPolicyT RefCountPolicyType
;
81 typedef PointerMFieldBase MFieldBaseType
;
82 typedef PointerSFieldBase SFieldBaseType
;
84 typedef ChildPointerMFieldBase
<Self
, 0> MFieldType
;
85 typedef ChildPointerSFieldBase
<Self
, 0> SFieldType
;
88 /*---------------------------------------------------------------------*/
89 /*! \name Access Handling */
92 static void onAdd (SFieldBaseType
* const pSField
,
93 FieldContainer
* const pObj
);
94 static void onAdd (MFieldBaseType
* const pMField
,
95 FieldContainer
* const pObj
);
97 static void onSub (SFieldBaseType
* const pSField
,
98 FieldContainer
* const pObj
);
99 static void onSub (MFieldBaseType
* const pMField
,
100 FieldContainer
* const pObj
);
102 static void onReplace(SFieldBaseType
* const pSField
,
103 FieldContainer
* const pOldObj
,
104 FieldContainer
* const pNewObj
);
105 static void onReplace(MFieldBaseType
* const pMField
,
106 FieldContainer
* const pOldObj
,
107 FieldContainer
* const pNewObj
);
110 /*---------------------------------------------------------------------*/
111 /*! \name Sync Access Handling */
114 static void onSyncAdd (SFieldBaseType
* const pSField
,
115 FieldContainer
* const pObj
);
116 static void onSyncAdd (MFieldBaseType
* const pMField
,
117 FieldContainer
* const pObj
);
119 static void onSyncSub (SFieldBaseType
* const pSField
,
120 FieldContainer
* const pObj
);
121 static void onSyncSub (MFieldBaseType
* const pMField
,
122 FieldContainer
* const pObj
);
124 static void onSyncReplace(SFieldBaseType
* const pSField
,
125 FieldContainer
* const pOldObj
,
126 FieldContainer
* const pNewObj
);
127 static void onSyncReplace(MFieldBaseType
* const pMField
,
128 FieldContainer
* const pOldObj
,
129 FieldContainer
* const pNewObj
);
132 /*---------------------------------------------------------------------*/
134 template <class ObjectT
>
135 static ObjectT
*validate(ObjectT
* const pObject
)
137 return RefCountPolicyType::validate(pObject
);
140 /*========================== PRIVATE ================================*/
144 /*---------------------------------------------------------------------*/
145 /*! \name Internal Helper */
148 static SFieldType
* dcastSField(SFieldBaseType
* const pSField
);
149 static MFieldType
* dcastMField(MFieldBaseType
* const pMField
);
152 /*---------------------------------------------------------------------*/
156 // static void unlinkChild (FieldContainerPtrConst pChild,
157 // UInt16 const parentFieldId );
158 static void linkParent (FieldContainer
* const pParent
,
159 UInt16
const childFieldId
,
160 FieldContainer
* const pChild
,
161 UInt16
const parentFieldId
);
162 static void unlinkParent(FieldContainer
* const pParent
,
163 FieldContainer
* const pChild
,
164 UInt16
const parentFieldId
);
167 /*---------------------------------------------------------------------*/
170 /*! \ingroup GrpBaseFieldContainerFields */
171 typedef ChildAccessHandler
<UnrecordedRefCountPolicy
> UnrecChildAccessHandler
;
175 #include "OSGChildAccessHandler.inl"
177 #endif // _OSGCHILDACCESSHANDLER_H_