OSGAttachmentMapFields.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *           Copyright (C) 2003 by the OpenSG Forum                          *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 //---------------------------------------------------------------------------
00040 //  Includes
00041 //---------------------------------------------------------------------------
00042 
00043 #include <OSGFieldContainer.h>
00044 #include <OSGAttachmentMapSFields.h>
00045 #include <OSGFieldContainerAttachment.h>
00046 #include <OSGAttachmentContainer.h>
00047 #include <OSGContainerPtrFuncs.h>
00048 
00049 #include <OSGTypeBasePredicates.h>
00050 #include <OSGReflexiveContainerTypePredicates.h>
00051 
00052 #include <OSGSField.ins>
00053 
00054 #if defined(OSG_TMPL_STATIC_MEMBER_NEEDS_FUNCTION_INSTANTIATION) || \
00055     defined(OSG_TMPL_STATIC_MEMBER_NEEDS_CLASS_INSTANTIATION   )
00056 
00057 #include <OSGSFieldFuncs.ins>
00058 
00059 #endif
00060 
00061 //#include <OSGSFieldAdaptor.ins>
00062 
00063 
00064 OSG_BEGIN_NAMESPACE
00065 #if 0
00066 template <>
00067 void
00068 FieldDescription<SFFieldContainerAttachmentPtrMap::SFieldTraits,
00069                  SingleField                                    >::cloneValues(
00070     const Field                                  *pSrc,
00071     const UInt32                                  fieldId,
00072           FieldContainerPtrConstArg               pDst,
00073     const std::vector<const FieldContainerType*> &shareTypes,
00074     const std::vector<const FieldContainerType*> &ignoreTypes,
00075     const std::vector<UInt16>                    &shareGroupIds,
00076     const std::vector<UInt16>                    &ignoreGroupIds) const
00077 {
00078     const SFFieldContainerAttachmentPtrMap *pAttMap =
00079         static_cast<const SFFieldContainerAttachmentPtrMap *>(pSrc);
00080     FieldContainerAttachmentMap::const_iterator mapIt  =
00081         pAttMap->getValue().begin();
00082     FieldContainerAttachmentMap::const_iterator mapEnd =
00083         pAttMap->getValue().end();
00084     AttachmentContainerPtr pDstAC = dynamic_cast<AttachmentContainerPtr>(pDst);
00085 
00086     for(; mapIt != mapEnd; ++mapIt)
00087     {
00088         FieldContainerAttachmentPtr att       = mapIt->second;
00089         UInt16                      uiBinding = UInt16(mapIt->first &
00090                                                        0x0000FFFF    );
00091 
00092         if(att != NullFC)
00093         {
00094             const FieldContainerType &attType = att->getType();
00095 
00096             // test if fc type should NOT be ignored
00097             if(!TypePredicates::typeInGroupIds (ignoreGroupIds.begin(),
00098                                                 ignoreGroupIds.end(),
00099                                                 attType                ) &&
00100                !TypePredicates::typeDerivedFrom(ignoreTypes.begin(),
00101                                                 ignoreTypes.end(),
00102                                                 attType                )   )
00103             {
00104                 // test if fc should NOT be shared
00105                 if(!TypePredicates::typeInGroupIds (shareGroupIds.begin(),
00106                                                     shareGroupIds.end(),
00107                                                     attType               ) &&
00108                    !TypePredicates::typeDerivedFrom(shareTypes.begin(),
00109                                                     shareTypes.end(),
00110                                                     attType               )   )
00111                 {
00112                     att = dynamic_cast<FieldContainerAttachmentPtr>(
00113                         OSG::deepClone(att, shareTypes,    ignoreTypes,
00114                                             shareGroupIds, ignoreGroupIds));
00115                 }
00116             }
00117         }
00118 
00119         pDstAC->addAttachment(att, uiBinding);
00120     }
00121 }
00122 
00123 template <>
00124 void
00125 FieldDescription<SFFieldContainerAttachmentPtrMap::SFieldTraits,
00126                  SingleField                                    >::shareValues(
00127     const Field                                  *pSrc,
00128     const UInt32                                  fieldId,
00129           FieldContainerPtrConstArg               pDst,
00130     const std::vector<const FieldContainerType*> &cloneTypes,
00131     const std::vector<const FieldContainerType*> &ignoreTypes,
00132     const std::vector<UInt16>                    &cloneGroupIds,
00133     const std::vector<UInt16>                    &ignoreGroupIds) const
00134 {
00135     const SFFieldContainerAttachmentPtrMap *pAttMap =
00136         static_cast<const SFFieldContainerAttachmentPtrMap *>(pSrc);
00137     FieldContainerAttachmentMap::const_iterator mapIt  =
00138         pAttMap->getValue().begin();
00139     FieldContainerAttachmentMap::const_iterator mapEnd =
00140         pAttMap->getValue().end();
00141     AttachmentContainerPtr pDstAC = dynamic_cast<AttachmentContainerPtr>(pDst);
00142 
00143     for(; mapIt != mapEnd; ++mapIt)
00144     {
00145         FieldContainerAttachmentPtr att       = mapIt->second;
00146         UInt16                      uiBinding = UInt16(mapIt->first &
00147                                                        0x0000FFFF    );
00148 
00149         if(att != NullFC)
00150         {
00151             const FieldContainerType &attType = att->getType();
00152 
00153             // test if att type should NOT be ignored
00154             if(!TypePredicates::typeInGroupIds (ignoreGroupIds.begin(),
00155                                                 ignoreGroupIds.end(),
00156                                                 attType                ) &&
00157                !TypePredicates::typeDerivedFrom(ignoreTypes.begin(),
00158                                                 ignoreTypes.end(),
00159                                                 attType                )   )
00160             {
00161                 // test if att should cloned
00162                 if(TypePredicates::typeInGroupIds (cloneGroupIds.begin(),
00163                                                    cloneGroupIds.end(),
00164                                                    attType               ) ||
00165                    TypePredicates::typeDerivedFrom(cloneTypes.begin(),
00166                                                    cloneTypes.end(),
00167                                                    attType               )   )
00168                 {
00169                     att = dynamic_cast<FieldContainerAttachmentPtr>(
00170                         OSG::deepClone(att, cloneTypes,    ignoreTypes,
00171                                             cloneGroupIds, ignoreGroupIds));
00172                 }
00173             }
00174         }
00175 
00176         pDstAC->addAttachment(att, uiBinding);
00177     }
00178 }
00179 #endif
00180 
00181 #if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
00182 
00183 DataType FieldTraits<FieldBundleAttachmentMap   >::_type(
00184     "FieldBundleAttachmentMap",
00185     NULL);
00186 
00187 DataType FieldTraits<FieldContainerAttachmentMap>::_type(
00188     "FieldContainerAttachmentMap",
00189     NULL);
00190 
00191 OSG_FIELDTRAITS_GETTYPE(FieldBundleAttachmentMap   )
00192 OSG_FIELDTRAITS_GETTYPE(FieldContainerAttachmentMap)
00193 
00194 #endif // !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
00195 
00196 OSG_FIELD_DLLEXPORT_DEF1(SField, FieldBundleAttachmentMap);
00197 OSG_FIELD_DLLEXPORT_DEF1(SField, FieldContainerAttachmentMap);
00198 
00199 OSG_END_NAMESPACE