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 _OSGFIELDCONTAINERIMPL_INL_
00040 #define _OSGFIELDCONTAINERIMPL_INL_
00041
00042 #ifdef OSG_DOC_FILES_IN_MODULE
00043
00046 #endif
00047
00048 #include <stdlib.h>
00049 #include <stdio.h>
00050
00051 #include "OSGConfig.h"
00052
00053 OSG_BEGIN_NAMESPACE
00054
00055
00056
00057
00058 inline
00059 FieldContainerType &FieldContainer::getClassType(void)
00060 {
00061 return _type;
00062 }
00063
00064 inline
00065 UInt32 FieldContainer::getClassTypeId(void)
00066 {
00067 return _type.getId();
00068 }
00069
00070 inline
00071 UInt16 FieldContainer::getClassGroupId(void)
00072 {
00073 return _type.getGroupId();
00074 }
00075
00076 inline
00077 UInt32 FieldContainer::getTypeId(void) const
00078 {
00079 return getType().getId();
00080 }
00081
00082 inline
00083 UInt16 FieldContainer::getGroupId(void) const
00084 {
00085 return getType().getGroupId();
00086 }
00087
00088 inline
00089 const Char8 *FieldContainer::getTypeName(void) const
00090 {
00091 return getType().getCName();
00092 }
00093
00094 inline
00095 Field *FieldContainer::getField(UInt32 fieldId)
00096 {
00097 const FieldDescription *desc = getType().getFieldDescription(fieldId);
00098
00099 return desc ? desc->getField(*this) : NULL;
00100 }
00101
00102 inline
00103 Field *FieldContainer::getField(const Char8 *fieldName)
00104 {
00105 const FieldDescription *desc =getType().findFieldDescription(fieldName);
00106
00107 return desc ? desc->getField(*this) : NULL;
00108 }
00109
00110
00111
00112
00113 inline
00114 FieldContainer::FieldContainer(void) :
00115 _shares(0)
00116 {
00117 }
00118
00119 inline
00120 FieldContainer::FieldContainer(const FieldContainer &) :
00121 _shares(0)
00122
00123 {
00124 }
00125
00126
00127
00128
00129 inline
00130 FieldContainer::~FieldContainer(void)
00131 {
00132 }
00133
00134
00135
00136
00137 template <class ObjectPtrT> inline
00138 void FieldContainer::newPtr(
00139 ObjectPtrT &result,
00140 const typename ObjectPtrT::StoredObjectType *prototypeP)
00141 {
00142 typedef typename ObjectPtrT::StoredObjectType ObjectType;
00143
00144 UInt8 *pTmp;
00145
00146 result._containerSize = sizeof(ObjectType);
00147
00148 pTmp =
00149 static_cast<UInt8 *>(operator new(
00150 sizeof(Int32) +
00151 sizeof(UInt32) +
00152 sizeof(ObjectType) * ThreadManager::getNumAspects()));
00153
00154 *(reinterpret_cast<Int32 *>(pTmp)) = 0;
00155
00156 pTmp += sizeof(Int32);
00157
00158 result._storeP = (pTmp + sizeof(UInt32));
00159
00160 #ifdef OSG_DEBUG_FCPTR
00161 result._typedStoreP = reinterpret_cast<FieldContainer *>(result._storeP);
00162 #endif
00163
00164 *(reinterpret_cast<UInt32 *>(pTmp)) =
00165 FieldContainerFactory::the()->registerFieldContainer(result);
00166
00167 Thread::getCurrentChangeList()->addCreated(
00168 *(reinterpret_cast<UInt32 *>(pTmp)));
00169
00170 pTmp += sizeof(UInt32);
00171
00172 ObjectType *aObject = reinterpret_cast<ObjectType *>(pTmp);
00173
00174 for(UInt32 i = 0; i < ThreadManager::getNumAspects(); i++)
00175 {
00176 pTmp =
00177 reinterpret_cast<UInt8 *>(new (pTmp) ObjectType(*prototypeP));
00178
00179 pTmp += sizeof(ObjectType);
00180 }
00181
00182 result->onCreate(prototypeP);
00183
00184 for(UInt32 i = 0; i < ThreadManager::getNumAspects(); i++)
00185 {
00186 aObject[i].onCreateAspect(aObject, prototypeP);
00187 }
00188
00189 #if defined(OSG_GV_BETA) && defined(OSG_DBG_MEM)
00190
00191 fprintf(stderr, "GV_MEM_FC_DBG : (%u) cc (%p|%u)\n",
00192 Thread::getAspect(),
00193 result._storeP,
00194
00195 ObjectType::getClassType().getId());
00196 #endif
00197
00198 #ifdef OSG_DEBUG_TYPED_FCPTR
00199 result.updateTypedStore();
00200 #endif
00201 }
00202
00203 template <class ObjectPtrT> inline
00204 void FieldContainer::newPtr(ObjectPtrT &result)
00205 {
00206 typedef typename ObjectPtrT::StoredObjectType ObjectType;
00207
00208 UInt8 *pTmp;
00209
00210 result._containerSize = sizeof(ObjectType);
00211
00212 pTmp =
00213 static_cast<UInt8 *>(operator new(
00214 sizeof(Int32) +
00215 sizeof(UInt32) +
00216 sizeof(ObjectType) * ThreadManager::getNumAspects()));
00217
00218 *(reinterpret_cast<Int32 *>(pTmp)) = 0;
00219
00220 pTmp += sizeof(Int32);
00221
00222 result._storeP = (pTmp + sizeof(UInt32));
00223
00224 #ifdef OSG_DEBUG_FCPTR
00225 result._typedStoreP = reinterpret_cast<FieldContainer *>(result._storeP);
00226 #endif
00227
00228 *(reinterpret_cast<UInt32 *>(pTmp)) =
00229 FieldContainerFactory::the()->registerFieldContainer(result);
00230
00231 Thread::getCurrentChangeList()->addCreated(
00232 *(reinterpret_cast<UInt32 *>(pTmp)));
00233
00234 pTmp += sizeof(UInt32);
00235
00236 ObjectType *aObject = reinterpret_cast<ObjectType *>(pTmp);
00237
00238 for(UInt32 i = 0; i < ThreadManager::getNumAspects(); i++)
00239 {
00240 pTmp = reinterpret_cast<UInt8 *>(new (pTmp) ObjectType());
00241
00242 pTmp += sizeof(ObjectType);
00243 }
00244
00245 result->onCreate();
00246
00247 for(UInt32 i = 0; i < ThreadManager::getNumAspects(); i++)
00248 {
00249 aObject[i].onCreateAspect(aObject);
00250 }
00251
00252 #if defined(OSG_GV_BETA) && defined(OSG_DBG_MEM)
00253 fprintf(stderr, "GV_MEM_FC_DBG : (%u) c (%p|%u)\n",
00254 Thread::getAspect(),
00255 result._storeP,
00256
00257 ObjectType::getClassType().getId());
00258 #endif
00259
00260 #ifdef OSG_DEBUG_TYPED_FCPTR
00261 result.updateTypedStore();
00262 #endif
00263 }
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 template<class FieldTypeT> inline
00285 void FieldContainer::beginEditX(const BitVector &, FieldTypeT &)
00286 {
00287
00288 }
00289
00290 template<class FieldTypeT> inline
00291 void FieldContainer::endEditX(const BitVector &whichField, FieldTypeT &)
00292 {
00293 FieldContainerPtr tmpPtr(this);
00294 endEditCP(tmpPtr, whichField);
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 inline
00318 void FieldContainer::onCreate(const FieldContainer *)
00319 {
00320 }
00321
00322 inline
00323 void FieldContainer::onCreateAspect(const FieldContainer *,
00324 const FieldContainer *)
00325 {
00326 }
00327
00328
00329
00330
00331 #if !defined(OSG_FIXED_MFIELDSYNC)
00332 inline
00333 void FieldContainer::executeSyncImpl( FieldContainer *,
00334 const BitVector &)
00335 {
00336 }
00337 #else
00338 inline
00339 void FieldContainer::executeSyncImpl( FieldContainer *,
00340 const BitVector &,
00341 const SyncInfo &)
00342 {
00343 }
00344
00345 inline
00346 void FieldContainer::execBeginEditImpl (const BitVector &whichField,
00347 UInt32 uiAspect,
00348 UInt32 uiContainerSize)
00349 {
00350 }
00351
00352 #endif
00353
00354 OSG_END_NAMESPACE
00355
00356 #define OSGFIELDCONTAINER_INLINE_CVSID "@(#)$Id: $"
00357
00358 #endif
00359
00360