00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSG_ATTACHMENTMAPFIELDDATATYPE_H_
00040 #define _OSG_ATTACHMENTMAPFIELDDATATYPE_H_
00041
00042 #include <OSGFieldDataType.h>
00043 #include <OSGFieldContainerFieldDataType.h>
00044 #include <OSGFieldContainerPtrForward.h>
00045 #include <OSGAttachmentPtr.h>
00046
00047 #include <map>
00048
00049 OSG_BEGIN_NAMESPACE
00050
00051 typedef std::map<UInt32, AttachmentPtr> AttachmentMap;
00052
00053 #if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
00054
00055 #ifdef OSG_DOC_FILES_IN_MODULE
00056
00060 #endif
00061
00064 #if !defined(OSG_DOC_DEV_TRAITS)
00065
00066 #endif
00067
00068 template <>
00069 struct FieldTraitsRecurseMapper<AttachmentMap, false> :
00070 public FieldTraitsRecurseBase<AttachmentMap>
00071 {
00072 enum { bHasParent = 0x00 };
00073
00074 static UInt32 getBinSize(const AttachmentMap &oObject)
00075 {
00076 AttachmentMap::const_iterator mapIt = oObject.begin();
00077 AttachmentMap::const_iterator mapEnd = oObject.end();
00078
00079 UInt32 uiNumPublicObjects = 0;
00080
00081 while(mapIt != mapEnd)
00082 {
00083 if(mapIt->second->getInternal().getValue() == false)
00084 {
00085 ++uiNumPublicObjects;
00086 }
00087
00088 ++mapIt;
00089 }
00090
00091 return sizeof(UInt32) +
00092 uiNumPublicObjects * (sizeof(UInt16) + sizeof(UInt32));
00093 }
00094
00095 static UInt32 getBinSize(const AttachmentMap *pObjectStore,
00096 UInt32 uiNumObjects)
00097 {
00098 UInt32 size = 0;
00099
00100
00101 for(UInt32 i = 0; i < uiNumObjects; ++i)
00102 {
00103 size += getBinSize(pObjectStore[i]);
00104 }
00105
00106 return size;
00107 }
00108
00109 static void copyToBin( BinaryDataHandler &pMem,
00110 const AttachmentMap &pObject)
00111 {
00112 UInt16 binding;
00113 UInt32 id;
00114 UInt32 uiNumPublicObjects = 0;
00115
00116 AttachmentMap::const_iterator mapIt = pObject.begin();
00117 AttachmentMap::const_iterator mapEnd = pObject.end();
00118
00119 while(mapIt != mapEnd)
00120 {
00121 if(mapIt->second->getInternal().getValue() == false)
00122 {
00123 ++uiNumPublicObjects;
00124 }
00125
00126 ++mapIt;
00127 }
00128
00129 pMem.putValue(uiNumPublicObjects);
00130
00131 mapIt = pObject.begin();
00132
00133 for(; mapIt != mapEnd; ++mapIt)
00134 {
00135 if(mapIt->second->getInternal().getValue() == false)
00136 {
00137 binding = mapIt->first & 0xffff;
00138 id = mapIt->second.getFieldContainerId();
00139
00140 pMem.putValue(binding);
00141 pMem.putValue(id);
00142 }
00143 }
00144 }
00145
00146 static void copyToBin( BinaryDataHandler &pMem,
00147 const AttachmentMap *pObjectStore,
00148 UInt32 uiNumObjects)
00149 {
00150 for(UInt32 i = 0; i < uiNumObjects; ++i)
00151 {
00152 copyToBin(pMem, pObjectStore[i]);
00153 }
00154 }
00155
00156 static void copyFromBin(BinaryDataHandler &pMem,
00157 AttachmentMap &pObject)
00158 {
00159 FieldContainerPtr fcp;
00160
00161 UInt32 key;
00162 UInt16 binding;
00163 UInt32 id;
00164 UInt32 size;
00165
00166 pMem.getValue(size);
00167
00168 pObject.clear();
00169
00170 for(UInt32 i = 0; i < size; ++i)
00171 {
00172 pMem.getValue(binding);
00173 pMem.getValue(id);
00174
00175 fcp = FieldContainerFactory::the()->getMappedContainer(id);
00176
00177 key = (UInt32 (fcp->getGroupId()) << 16) | binding;
00178
00179 ((FieldContainerPtr &) pObject[key]) = fcp;
00180 }
00181 }
00182
00183 static void copyFromBin(BinaryDataHandler &pMem,
00184 AttachmentMap *pObjectStore,
00185 UInt32 uiNumObjects)
00186 {
00187 for(UInt32 i = 0; i < uiNumObjects; ++i)
00188 {
00189 copyFromBin(pMem, pObjectStore[i]);
00190 }
00191 }
00192 };
00193
00194 #if !defined(OSG_DOC_DEV_TRAITS)
00195
00197 #endif
00198
00201 #if !defined(OSG_DOC_DEV_TRAITS)
00202
00203 #endif
00204
00205 template <>
00206 struct OSG_SYSTEMLIB_DLLMAPPING FieldDataTraits<AttachmentMap> :
00207 public FieldTraitsRecurseMapper<AttachmentMap, false>
00208 {
00209 static DataType _type;
00210
00211 enum { StringConvertable = 0x01 };
00212 enum { bHasParent = 0x00 };
00213
00214 static DataType &getType (void) { return _type; }
00215 static char *getSName(void) { return "SFAttachmentMap"; }
00216 static char *getMName(void) { return "MFAttachmentMap"; }
00217
00218 static bool getFromString( AttachmentMap &,
00219 const Char8 *&)
00220 {
00221 return false;
00222 }
00223
00224 static void putToString (const AttachmentMap &,
00225 std::string &outStr)
00226 {
00227 outStr.assign("AttachmentMap");
00228 }
00229 };
00230
00231 #if !defined(OSG_DOC_DEV_TRAITS)
00232
00234 #endif
00235
00236 #endif // !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
00237
00238 OSG_END_NAMESPACE
00239
00240 #define OSGATTACHMENTMAPFIELDDATATYPE_HEADER_CVSID "@(#)$Id: $"
00241
00242 #endif
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254