changed: gcc8 base update
[opensg.git] / Source / Base / FieldContainer / Fields / OSGFieldContainerFields.cpp
blob419282be2b9f9ce29ceeabd7b36baecbddbf57ad
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2003 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 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include "OSGFieldContainerSFields.h"
44 #include "OSGFieldContainerMFields.h"
46 #include "OSGTypeBasePredicates.h"
47 #include "OSGReflexiveContainerTypePredicates.h"
49 OSG_BEGIN_NAMESPACE
50 #if 0
51 template<>
52 void
53 FieldDescription<FieldTraits<FieldContainerPtr>,
54 SingleField >::cloneValues(
55 const Field *pSrc,
56 const UInt32 fieldId,
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();
66 if(fc != NullFC)
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);
86 else
88 fc = NullFC;
92 pDst->pushToField(fc, fieldId);
95 template<>
96 void
97 FieldDescription<FieldTraits<FieldContainerPtr>,
98 MultiField >::cloneValues(
99 const Field *pSrc,
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;
117 if(fc != NullFC)
119 const FieldContainerType& fcType = fc->getType();
121 // test if fc type should NOT be ignored
122 if(!TypePredicates::typeInGroupIds (ignoreGroupIds.begin(),
123 ignoreGroupIds.end(),
124 fcType ) &&
125 !TypePredicates::typeDerivedFrom(ignoreTypes.begin(),
126 ignoreTypes.end(),
127 fcType ) )
129 // test if fc should NOT be shared
130 if(!TypePredicates::typeInGroupIds (shareGroupIds.begin(),
131 shareGroupIds.end(),
132 fcType ) &&
133 !TypePredicates::typeDerivedFrom(shareTypes.begin(),
134 shareTypes.end(),
135 fcType ) )
137 fc = OSG::deepClone(fc, shareTypes, ignoreTypes,
138 shareGroupIds, ignoreGroupIds);
143 pDst->pushToField(fc, fieldId);
147 template <>
148 void
149 FieldDescription<FieldTraits<FieldContainerPtr>,
150 SingleField >::shareValues(
151 const Field *pSrc,
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();
162 if(fc != NullFC)
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);
182 else
184 fc = NullFC;
188 pDst->pushToField(fc, fieldId);
191 template <>
192 void
193 FieldDescription<FieldTraits<FieldContainerPtr>,
194 MultiField >::shareValues(
195 const Field *pSrc,
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;
213 if(fc != NullFC)
215 const FieldContainerType& fcType = fc->getType();
217 // test if att type should NOT be ignored
218 if(!TypePredicates::typeInGroupIds (ignoreGroupIds.begin(),
219 ignoreGroupIds.end(),
220 fcType ) &&
221 !TypePredicates::typeDerivedFrom(ignoreTypes.begin(),
222 ignoreTypes.end(),
223 fcType ) )
225 // test if att should cloned
226 if(TypePredicates::typeInGroupIds (cloneGroupIds.begin(),
227 cloneGroupIds.end(),
228 fcType ) ||
229 TypePredicates::typeDerivedFrom(cloneTypes.begin(),
230 cloneTypes.end(),
231 fcType ) )
233 fc = OSG::deepClone(fc, cloneTypes, ignoreTypes,
234 cloneGroupIds, ignoreGroupIds);
239 pDst->pushToField(fc, fieldId);
242 #endif
244 OSG_END_NAMESPACE