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 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
43 #include "OSGFieldContainerSFields.h"
44 #include "OSGFieldContainerMFields.h"
46 #include "OSGTypeBasePredicates.h"
47 #include "OSGReflexiveContainerTypePredicates.h"
53 FieldDescription
<FieldTraits
<FieldContainerPtr
>,
54 SingleField
>::cloneValues(
57 FieldContainerPtrConstArg pDst
,
58 const std::vector
<const FieldContainerType
*> &shareTypes
,
59 const std::vector
<const FieldContainerType
*> &ignoreTypes
,
60 const std::vector
<UInt16
> &shareGroupIds
,
61 const std::vector
<UInt16
> &ignoreGroupIds
) const
63 FieldContainerPtr fc
=
64 static_cast<const SFFieldContainerPtr
*>(pSrc
)->getValue();
68 const FieldContainerType
& fcType
= fc
->getType();
70 // test if fc type should NOT be ignored
71 if(!TypePredicates::typeInGroupIds (ignoreGroupIds
.begin(),
72 ignoreGroupIds
.end(), fcType
) &&
73 !TypePredicates::typeDerivedFrom(ignoreTypes
.begin(),
74 ignoreTypes
.end(), fcType
) )
76 // test if fc should NOT be shared
77 if(!TypePredicates::typeInGroupIds (shareGroupIds
.begin(),
78 shareGroupIds
.end(), fcType
) &&
79 !TypePredicates::typeDerivedFrom(shareTypes
.begin(),
80 shareTypes
.end(), fcType
) )
82 fc
= OSG::deepClone(fc
, shareTypes
, ignoreTypes
,
83 shareGroupIds
, ignoreGroupIds
);
92 pDst
->pushToField(fc
, fieldId
);
97 FieldDescription
<FieldTraits
<FieldContainerPtr
>,
98 MultiField
>::cloneValues(
100 const UInt32 fieldId
,
101 FieldContainerPtrConstArg pDst
,
102 const std::vector
<const FieldContainerType
*> &shareTypes
,
103 const std::vector
<const FieldContainerType
*> &ignoreTypes
,
104 const std::vector
<UInt16
> &shareGroupIds
,
105 const std::vector
<UInt16
> &ignoreGroupIds
) const
107 const MFFieldContainerPtr
*pFCField
=
108 static_cast<const MFFieldContainerPtr
*>(pSrc
);
109 MFFieldContainerPtr::const_iterator fieldIter
= pFCField
->begin();
110 MFFieldContainerPtr::const_iterator fieldEnd
= pFCField
->end();
112 // TODO: Could this be optimized by checking ignore/share just once ?
113 for(; fieldIter
!= fieldEnd
; ++fieldIter
)
115 FieldContainerPtr fc
= *fieldIter
;
119 const FieldContainerType
& fcType
= fc
->getType();
121 // test if fc type should NOT be ignored
122 if(!TypePredicates::typeInGroupIds (ignoreGroupIds
.begin(),
123 ignoreGroupIds
.end(),
125 !TypePredicates::typeDerivedFrom(ignoreTypes
.begin(),
129 // test if fc should NOT be shared
130 if(!TypePredicates::typeInGroupIds (shareGroupIds
.begin(),
133 !TypePredicates::typeDerivedFrom(shareTypes
.begin(),
137 fc
= OSG::deepClone(fc
, shareTypes
, ignoreTypes
,
138 shareGroupIds
, ignoreGroupIds
);
143 pDst
->pushToField(fc
, fieldId
);
149 FieldDescription
<FieldTraits
<FieldContainerPtr
>,
150 SingleField
>::shareValues(
152 const UInt32 fieldId
,
153 FieldContainerPtrConstArg pDst
,
154 const std::vector
<const FieldContainerType
*> &cloneTypes
,
155 const std::vector
<const FieldContainerType
*> &ignoreTypes
,
156 const std::vector
<UInt16
> &cloneGroupIds
,
157 const std::vector
<UInt16
> &ignoreGroupIds
) const
159 FieldContainerPtr fc
=
160 static_cast<const SFFieldContainerPtr
*>(pSrc
)->getValue();
164 const FieldContainerType
& fcType
= fc
->getType();
166 // test if att type should NOT be ignored
167 if(!TypePredicates::typeInGroupIds (ignoreGroupIds
.begin(),
168 ignoreGroupIds
.end(), fcType
) &&
169 !TypePredicates::typeDerivedFrom(ignoreTypes
.begin(),
170 ignoreTypes
.end(), fcType
) )
172 // test if att should cloned
173 if(TypePredicates::typeInGroupIds (cloneGroupIds
.begin(),
174 cloneGroupIds
.end(), fcType
) ||
175 TypePredicates::typeDerivedFrom(cloneTypes
.begin(),
176 cloneTypes
.end(), fcType
) )
178 fc
= OSG::deepClone(fc
, cloneTypes
, ignoreTypes
,
179 cloneGroupIds
, ignoreGroupIds
);
188 pDst
->pushToField(fc
, fieldId
);
193 FieldDescription
<FieldTraits
<FieldContainerPtr
>,
194 MultiField
>::shareValues(
196 const UInt32 fieldId
,
197 FieldContainerPtrConstArg pDst
,
198 const std::vector
<const FieldContainerType
*> &cloneTypes
,
199 const std::vector
<const FieldContainerType
*> &ignoreTypes
,
200 const std::vector
<UInt16
> &cloneGroupIds
,
201 const std::vector
<UInt16
> &ignoreGroupIds
) const
203 const MFFieldContainerPtr
*pFCField
=
204 static_cast<const MFFieldContainerPtr
*>(pSrc
);
205 MFFieldContainerPtr::const_iterator fieldIter
= pFCField
->begin();
206 MFFieldContainerPtr::const_iterator fieldEnd
= pFCField
->end();
208 // TODO: Could this be optimized by checking ignore/clone just once ?
209 for(; fieldIter
!= fieldEnd
; ++fieldIter
)
211 FieldContainerPtr fc
= *fieldIter
;
215 const FieldContainerType
& fcType
= fc
->getType();
217 // test if att type should NOT be ignored
218 if(!TypePredicates::typeInGroupIds (ignoreGroupIds
.begin(),
219 ignoreGroupIds
.end(),
221 !TypePredicates::typeDerivedFrom(ignoreTypes
.begin(),
225 // test if att should cloned
226 if(TypePredicates::typeInGroupIds (cloneGroupIds
.begin(),
229 TypePredicates::typeDerivedFrom(cloneTypes
.begin(),
233 fc
= OSG::deepClone(fc
, cloneTypes
, ignoreTypes
,
234 cloneGroupIds
, ignoreGroupIds
);
239 pDst
->pushToField(fc
, fieldId
);