osg::RemoteAspect Class Reference
[Cluster]

Remote aspect controll class. More...

#include <OSGRemoteAspect.h>

List of all members.

Public Types

enum  DataTypes {
  SYNCENDED = 1, CREATED = 2, DESTROYED = 3, NEWTYPE = 4,
  CHANGED = 5, ADDREFED = 6, SUBREFED = 7, IDMAPPING = 8,
  PASSOVER = 9
}
typedef ArgsCollector
< RemoteAspect * > 
FunctorArgs
typedef TypedFunctor2Base
< bool, CPtrRefCallArg
< FieldContainerPtr >
, FunctorArgs
Functor
typedef std::map< UInt64, UInt32LocalFCMapT
typedef std::map< UInt32, UInt64RemoteFCMapT
typedef std::map< UInt32, UInt32LocalTypeMapT
typedef std::set< UInt32IdSetT
typedef std::map< UInt32,
BitVector
FieldFilterT
typedef std::map< UInt32,
BitVector
FieldMaskMapT

Public Member Functions

Constructors



 RemoteAspect (UInt32 aspectId=0)
virtual ~RemoteAspect (void)
Statistics



void setStatistics (StatCollector *stat)

Static Public Attributes

static stat elem



static StatElemDesc< StatTimeElemstatSyncTime

Protected Member Functions

protected helper functions



bool callCreated (FieldContainerPtr &node)
bool callDestroyed (FieldContainerPtr &node)
bool callChanged (FieldContainerPtr &node)

Private Member Functions

 RemoteAspect (const RemoteAspect &source)
RemoteAspectoperator= (const RemoteAspect &source)
Helper functions



void handleFCMapping (Connection &connection)
void clearFCMapping (UInt32 localId, UInt32 remoteId)
bool getLocalId (UInt32 remoteId, UInt32 &localId)
UInt64 getFullRemoteId (UInt32 remoteId)

Static Private Member Functions

static elements



static bool _defaultCreatedFunction (FieldContainerPtr &fcp, RemoteAspect *aspect)
static bool _defaultDestroyedFunction (FieldContainerPtr &fcp, RemoteAspect *aspect)
static bool _defaultChangedFunction (FieldContainerPtr &fcp, RemoteAspect *aspect)

Friends

class RemoteAspectFieldContainerMapper

Remote aspect functionaliy



typedef std::map< UInt32, UInt32clStoreMap
typedef clStoreMap::iterator clStoreIt
void receiveSync (Connection &connection, bool applyToChangelist=false)
void sendSync (Connection &connection, ChangeList *changeList=NULL)
void registerCreated (const FieldContainerType &type, const Functor &func)
void registerDestroyed (const FieldContainerType &type, const Functor &func)
void registerChanged (const FieldContainerType &type, const Functor &func)
static void addFieldFilter (UInt32 typeId, BitVector mask)
static void subFieldFilter (UInt32 typeId, BitVector mask)
static FieldFilterT const & getFieldFilter (void)
static BitVector getFieldFilter (UInt32 typeId)
static void restoreChangeList (ChangeList *tocl)
static void storeChangeList (ChangeList *cl)
static UInt32 getStoreSize (void)
static clStoreMapgetStore (void)
static void createCurrentStateChangeList (const FieldContainerPtr &start, ChangeList *cl)
static void createCurrentStateChangeList (ChangeList *cl)

Callbacks



typedef void(* synccbfp )(const std::string &msg, Int32 progress)
void setSendSyncCB (synccbfp fp)

member



UInt32 _aspectId
LocalFCMapT _localFC
RemoteFCMapT _remoteFC
LocalTypeMapT _localType
IdSetT _sentFC
IdSetT _receivedFC
IdSetT _mappedFC
IdSetT _mappedType
UInt32 _remoteAspectId
std::vector< Functor_createdFunctors
std::vector< Functor_destroyedFunctors
std::vector< Functor_changedFunctors
StatCollector_statistics
synccbfp _sendSyncFP
static FieldFilterT _fieldFilter
static std::map< UInt32, UInt32_clStore

Detailed Description

The RemoteAspecet is used to synchronize changes of FieldContainers with remote hosts. All changes stored in the current change list are send to a Connection.

It is possible to send changes in both directions.

Definition at line 60 of file OSGRemoteAspect.h.


Member Typedef Documentation

functor called for changed containers

Definition at line 79 of file OSGRemoteAspect.h.

Definition at line 82 of file OSGRemoteAspect.h.

Map remote to local id

Definition at line 85 of file OSGRemoteAspect.h.

Map local to remote id

Definition at line 87 of file OSGRemoteAspect.h.

Map remote to local type

Definition at line 89 of file OSGRemoteAspect.h.

typedef std::set<UInt32> osg::RemoteAspect::IdSetT

id set

Definition at line 92 of file OSGRemoteAspect.h.

Field filter map

Definition at line 95 of file OSGRemoteAspect.h.

Definition at line 96 of file OSGRemoteAspect.h.

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 130 of file OSGRemoteAspect.h.

typedef clStoreMap::iterator osg::RemoteAspect::clStoreIt

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 131 of file OSGRemoteAspect.h.

typedef void(* osg::RemoteAspect::synccbfp)(const std::string &msg, Int32 progress)

Definition at line 157 of file OSGRemoteAspect.h.


Member Enumeration Documentation

Message types

Enumerator:
SYNCENDED 
CREATED 
DESTROYED 
NEWTYPE 
CHANGED 
ADDREFED 
SUBREFED 
IDMAPPING 
PASSOVER 

Definition at line 65 of file OSGRemoteAspect.h.

00066     {
00067         SYNCENDED =1,
00068         CREATED   =2,
00069         DESTROYED =3,
00070         NEWTYPE   =4,
00071         CHANGED   =5,
00072         ADDREFED  =6,
00073         SUBREFED  =7,
00074         IDMAPPING =8,
00075         PASSOVER  =9
00076     };


Constructor & Destructor Documentation

RemoteAspect::RemoteAspect ( UInt32  aspectId = 0  ) 

Constructor

Definition at line 84 of file OSGRemoteAspect.cpp.

References _fieldFilter, osg::FieldContainerFactory::endTypes(), osg::WindowBase::getClassType(), osg::FragmentProgramChunkBase::getClassType(), osg::VertexProgramChunkBase::getClassType(), osg::CubeTextureChunkBase::getClassType(), osg::TextureChunkBase::getClassType(), osg::SurfaceBase::getClassType(), osg::GeometryBase::getClassType(), osg::TypeBase::getId(), osg::ProgramChunkBase::GLIdFieldMask, osg::TextureChunkBase::GLIdFieldMask, osg::GeometryBase::GLIdFieldMask, osg::WindowBase::GlObjectEventCounterFieldMask, osg::WindowBase::GlObjectLastRefreshFieldMask, osg::WindowBase::GlObjectLastReinitializeFieldMask, osg::SurfaceBase::SurfaceGLIdFieldMask, and osg::FieldContainerFactory::the().

00084                                           :
00085     _aspectId(aspectId),
00086 
00087     _localFC(),
00088     _remoteFC(),
00089     _localType(),
00090 
00091     _sentFC(),
00092     _receivedFC(),
00093     _mappedFC(),
00094     _mappedType(),
00095 
00096     _createdFunctors(),
00097     _destroyedFunctors(),
00098     _changedFunctors(),
00099     _statistics(NULL),
00100     _sendSyncFP(NULL)
00101 {
00102     FieldContainerFactory::TypeMapIterator  typeI;
00103 
00104     // initialize field filter
00105     _fieldFilter[Geometry::getClassType().getId()] = 
00106         Geometry::GLIdFieldMask;
00107     _fieldFilter[Surface::getClassType().getId()] = 
00108         Surface::GLIdFieldMask | Surface::SurfaceGLIdFieldMask;
00109     _fieldFilter[TextureChunk::getClassType().getId()] = 
00110         TextureChunk::GLIdFieldMask;
00111     _fieldFilter[CubeTextureChunk::getClassType().getId()] = 
00112         CubeTextureChunk::GLIdFieldMask;
00113     _fieldFilter[VertexProgramChunk::getClassType().getId()] = 
00114         VertexProgramChunk::GLIdFieldMask;
00115     _fieldFilter[FragmentProgramChunk::getClassType().getId()] = 
00116         FragmentProgramChunk::GLIdFieldMask;
00117 
00118     for(typeI = FieldContainerFactory::the()->beginTypes();
00119             typeI != FieldContainerFactory::the()->endTypes(); ++typeI)
00120     {
00121         if(typeI->second->isDerivedFrom(Window::getClassType()))
00122         {
00123             _fieldFilter[typeI->second->getId()
00124                     ] = Window::GlObjectEventCounterFieldMask |
00125                 Window::GlObjectLastRefreshFieldMask |
00126                 Window::GlObjectLastReinitializeFieldMask;
00127         }
00128     }
00129 }

RemoteAspect::~RemoteAspect ( void   )  [virtual]

Destructor

Definition at line 133 of file OSGRemoteAspect.cpp.

References _receivedFC, callDestroyed(), osg::AttachmentContainerPtr::dcast(), osg::NodePtr::dcast(), osg::FieldContainerFactory::getContainer(), osg::NullFC, osg::subRefCP(), and osg::FieldContainerFactory::the().

00134 {
00135     FieldContainerFactory   *factory = FieldContainerFactory::the();
00136     IdSetT::iterator        i;
00137     FieldContainerPtr       fcPtr;
00138     NodePtr                 node;
00139     WindowPtr               window;
00140 
00141     // subRef received field container
00142     for(i = _receivedFC.begin(); i != _receivedFC.end(); i++)
00143     {
00144         fcPtr = factory->getContainer(*i);
00145         if(fcPtr != NullFC)
00146         {
00147             callDestroyed(fcPtr);
00148 
00149             // currently it is not save to subref all
00150             // containers because we don't know whether
00151             // they are referenced by other nodes.
00152             // It's only save to remove nodes without parents
00153             node = NodePtr::dcast(fcPtr);
00154             if(node != NullFC)
00155             {
00156                 if(node->getParent() == NullFC)
00157                 {
00158                     do
00159                     {
00160                         subRefCP(fcPtr);
00161                         fcPtr = factory->getContainer(*i);
00162                     } while(fcPtr != NullFC);
00163                 }
00164             }
00165             window = WindowPtr::dcast(fcPtr);
00166             if(window != NullFC)
00167             {
00168                 do
00169                 {
00170                     subRefCP(fcPtr);
00171                     fcPtr = factory->getContainer(*i);
00172                 } while(fcPtr != NullFC);
00173             }
00174             /*
00175             // subref twice because we have two addrefs on reate
00176             // It is not possible to subref until the node is removed
00177             // because if this node is referenced by another node
00178             // then we will have a crash if we try to subref this
00179             // other node.
00180             subRefCP(fcPtr);
00181             subRefCP(fcPtr);
00182             */
00183         }
00184     }
00185 }

osg::RemoteAspect::RemoteAspect ( const RemoteAspect source  )  [private]

Member Function Documentation

void RemoteAspect::receiveSync ( Connection connection,
bool  applyToChangelist = false 
)

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 197 of file OSGRemoteAspect.cpp.

References _aspectId, _localFC, _localType, _receivedFC, osg::RemoteAspectFieldContainerMapper::_remoteAspect, _remoteAspectId, _remoteFC, _statistics, osg::addRefCP(), ADDREFED, osg::beginEditCP(), callChanged(), callCreated(), callDestroyed(), CHANGED, osg::changedCP(), clearFCMapping(), CREATED, osg::FieldContainerType::createFieldContainer(), DESTROYED, osg::endEditCP(), FDEBUG, osg::FieldContainerFactory::findType(), osg::BinaryDataHandler::get(), osg::Field::getCardinality(), osg::TypeBase::getCName(), osg::FieldContainerFactory::getContainer(), osg::getContainerId(), osg::StatCollector::getElem(), getFullRemoteId(), getLocalId(), osg::FieldDescription::getName(), osg::FieldContainerType::getNumFieldDescs(), osg::Field::getType(), osg::BinaryDataHandler::getValue(), IDMAPPING, NEWTYPE, osg::NullFC, PASSOVER, osg::Connection::selectChannel(), osg::FieldContainerFactory::setMapper(), SFATAL, osg::FieldType::SINGLE_FIELD, statSyncTime, osg::IDString::str(), osg::subRefCP(), SUBREFED, SWARNING, SYNCENDED, and osg::FieldContainerFactory::the().

Referenced by osg::ClusterServer::doSync().

00198 {
00199     bool                                finish = false;
00200     UInt8                               cmd;
00201     UInt32                              remoteTypeId;
00202     UInt32                              localTypeId;
00203     UInt32                              remoteId;
00204     UInt32                              localId;
00205     UInt32                              localAspect;
00206     std::string                         name;
00207     FieldContainerFactory               *factory = FieldContainerFactory::the();
00208     FieldContainerType                  *fcType;
00209     FieldContainerPtr                   fcPtr;
00210     BitVector                           mask;
00211     RemoteAspectFieldContainerMapper    mapper;
00212     UInt64                              fullRemoteId;
00213     LocalTypeMapT::iterator             localTypeI;
00214     LocalFCMapT::iterator               localFCI;
00215     UInt32                              len;
00216 
00217     // hack. No materialchange after image chagne
00218     std::vector<std::pair<FieldContainerPtr,BitVector> > changedFCs;
00219 
00220     if(_statistics)
00221     {
00222         _statistics->getElem(statSyncTime)->start();
00223     }
00224 
00225     connection.selectChannel();
00226     connection.getValue(_remoteAspectId);
00227 
00228     // register mapper into factory
00229     mapper._remoteAspect = this;
00230     factory->setMapper(&mapper);
00231     do
00232     {
00233         connection.getValue(cmd);
00234         switch(cmd)
00235         {
00236         case NEWTYPE:
00237             {
00238                 connection.getValue(remoteTypeId);
00239                 connection.getValue(name);
00240 
00241                 // find local type
00242                 fcType = FieldContainerFactory::the()->findType(name.c_str());
00243                 if(!fcType)
00244                 {
00245                     SWARNING << "Unknown Type: " << name << std::endl;
00246                 }
00247                 else
00248                 {
00249                     localTypeId = FieldContainerFactory::the()->findType(name.c_str())->getId();
00250 
00251                     // insert remote type id into map
00252                     _localType[remoteTypeId] = localTypeId;
00253                 }
00254                 break;
00255             }
00256 
00257         case CREATED:
00258             {
00259                 connection.getValue(remoteTypeId);
00260                 connection.getValue(remoteId);
00261                 localTypeI = _localType.find(remoteTypeId);
00262                 if(localTypeI == _localType.end())
00263                 {
00264                     SWARNING <<
00265                         "Unknown TypeID: " <<
00266                         remoteTypeId <<
00267                         " for remote id " <<
00268                         remoteId <<
00269                         std::endl;
00270                 }
00271                 else
00272                 {
00273                     UInt64 fullRemoteId=getFullRemoteId(remoteId);
00274                     if(_localFC.find(fullRemoteId) == _localFC.end())
00275                     {
00276                         localTypeId = localTypeI->second;
00277                         fcType = factory->findType(localTypeId);
00278                         fcPtr = fcType->createFieldContainer();
00279                         
00280                         // remove this node, when aspect is removed
00281                         _receivedFC.insert(getContainerId(fcPtr));
00282                         
00283                         // local <-> remote mapping
00284                         _localFC[fullRemoteId] = getContainerId(fcPtr);
00285                         _remoteFC[getContainerId(fcPtr)] = fullRemoteId;
00286                         
00287                         // make shure, client will not subref to zero
00288                         addRefCP(fcPtr);
00289                         addRefCP(fcPtr);
00290                         callCreated(fcPtr);
00291                     }
00292                     else
00293                     {
00294                         FDEBUG(("FC already created %d\n",remoteId));
00295                     }
00296                 }
00297                 break;
00298             }
00299 
00300         case DESTROYED:
00301             {
00302                 connection.getValue(remoteId);
00303                 if(getLocalId(remoteId,localId))
00304                 {
00305                     clearFCMapping(localId,remoteId);
00306                     fcPtr = factory->getContainer(localId);
00307                     if(fcPtr != NullFC)
00308                     {
00309                         callDestroyed(fcPtr);
00310 
00311                         // remove all references to avoid multiple
00312                         // removes.
00313                         // The changelist does not contain changes
00314                         // if the container was removed in this frame.
00315                         // So when a pointerfield is set to NullFC
00316                         // the new value is not transfered to the
00317                         // server.
00318                         FieldContainerType &fcType = fcPtr->getType();
00319                         for(UInt32 i = 1; i <= fcType.getNumFieldDescs(); ++i)
00320                         {
00321                             FieldDescription *desc = fcPtr->getType().getFieldDescription(i);
00322                             // ignore beacon fields. I don't know any clean
00323                             // solution. In CamearDecorator the acces method
00324                             // to beacon is overloaded. As a result, if the
00325                             // beacon field in the decorator is modified,
00326                             // the decorated camera is modified. In most
00327                             // cases this is OK, but not in this case.
00328                             if(strcmp(desc->getName().str(),"beacon")==0)
00329                                 continue;
00330                             Field *fieldPtr = fcPtr->getField(i);
00331                             const FieldType &fType = fieldPtr->getType();
00332                             const char *ptrStr = strstr(fType.getCName(), "Ptr");
00333                             if(ptrStr && strlen(ptrStr) == 3)
00334                             {
00335                                 if(fieldPtr->getCardinality() == FieldType::SINGLE_FIELD)
00336                                 {
00337                                     (static_cast<SFFieldContainerPtr *>(fieldPtr))->setValue(NullFC);
00338                                 }
00339                                 else 
00340                                 {
00341                                     (static_cast<MFFieldContainerPtr *>(fieldPtr))->clear();
00342                                 }
00343                             }
00344                         }
00345 
00346                         // subref until the factory hat no 
00347                         // knowlage of the node
00348                         // we can do this here because in sendSync the destroys are coming
00349                         // after the changes, that's important because if
00350                         // rebuildState would be called
00351                         // after the StateChunk has been destroyed this would lead to some
00352                         // problems because the StateChunk is also referenced
00353                         // in the state and in the next rebuildState of the material
00354                         // the old already invalid chunk ptr is destroyed again!
00355                         do
00356                         {
00357                             subRefCP(fcPtr);
00358                             fcPtr = factory->getContainer(localId);
00359                         }
00360                         while(fcPtr != NullFC);
00361                     }
00362                 }
00363                 else
00364                 {
00365                     SWARNING <<
00366                         "Can't destroy unknown FC:" <<
00367                         remoteId << " " <<
00368                         std::endl;
00369                 }
00370                 break;
00371             }
00372 
00373         case CHANGED:
00374             {
00375                 connection.getValue(remoteId);
00376                 connection.getValue(mask);
00377                 connection.getValue(len);
00378 
00379                 if(getLocalId(remoteId,localId))
00380                 {
00381                     fcPtr = factory->getContainer(localId);
00382 
00383                     if(applyToChangelist)
00384                     {
00385                         beginEditCP(fcPtr, mask);
00386                     }
00387 
00388                     /*
00389                     for(int i=0;i<fcPtr->getType().getNumFieldDescs();i++)
00390                     {
00391                         FieldDescription *desc=fcPtr->getType().getFieldDescription(i+1);
00392                         if(desc->getFieldMask() & mask)
00393                             cout<< "changed field: " << desc->getName() << std::endl;
00394                     }
00395                     */
00396                     fcPtr->copyFromBin(connection, mask);
00397                     if(applyToChangelist)
00398                     {
00399                         endEditCP(fcPtr, mask);
00400                     }
00401                     else
00402                     {
00403                         // do we need to call this?
00404                         changedCP(fcPtr, mask);
00405                     }
00406                     changedFCs.push_back(
00407                         std::pair<FieldContainerPtr,BitVector>(
00408                             fcPtr,mask));
00409                 }
00410                 else
00411                 {
00412                     char dummy;
00413 
00414                     SWARNING <<
00415                         "Can't change unknown FC:" <<
00416                         remoteId << " skip " << len << " bytes." <<
00417                         std::endl;
00418                     while(len--)
00419                         connection.get(&dummy,1);
00420                 }
00421                 break;
00422             }
00423 
00424         case SYNCENDED:
00425             {
00426                 finish = true;
00427                 break;
00428             }
00429 
00430         case ADDREFED:
00431             {
00432                 connection.getValue(remoteId);
00433                 if(getLocalId(remoteId,localId))
00434                 {
00435                     fcPtr = factory->getContainer(localId);
00436                     FDEBUG(("AddRef: %s ID:%d\n", 
00437                             fcPtr->getType().getName().str(),
00438                             getContainerId(fcPtr))) 
00439                     addRefCP(fcPtr);
00440                 }
00441                 else
00442                 {
00443                     FDEBUG(("Can't addref unknown FC:%d\n", remoteId));
00444                 }
00445                 break;
00446             }
00447 
00448         case SUBREFED:
00449             {
00450                 connection.getValue(remoteId);
00451                 if(getLocalId(remoteId,localId))
00452                 {
00453                     fcPtr = factory->getContainer(localId);
00454                     FDEBUG(("SubRef: %s ID:%d\n", 
00455                             fcPtr->getType().getName().str(),
00456                             getContainerId(fcPtr)))
00457 #if 0
00458                     //ignore until solution is found for subrefs in destructors
00459                     subRefCP(fcPtr);
00460 #endif
00461                 }
00462                 else
00463                 {
00464                     FDEBUG(("Can't subref unknown FC:%d\n", remoteId));
00465                 }
00466                 break;
00467             }
00468         case IDMAPPING:
00469             {
00470                 connection.getValue(remoteId);
00471                 connection.getValue(localAspect);
00472                 connection.getValue(localId);
00473                 if(localAspect != _aspectId)
00474                 {
00475                     SFATAL << "ID mapping for wrong aspect" << std::endl;
00476                 }
00477 
00478                 // local <-> remote mapping
00479                 fullRemoteId = getFullRemoteId(remoteId);
00480                 _localFC[fullRemoteId] = localId;
00481                 break;
00482             }
00483         case PASSOVER:
00484             // quite usefull if you want to send some custom unsynced stuff to the servers. 
00485             connection.getValue(_remoteAspectId);
00486             break;
00487         default:
00488             {
00489                 SFATAL << "Unknown tag:" << int(cmd) << std::endl;
00490                 throw RemoteSyncError();
00491             }
00492         }
00493     } 
00494     while(!finish);
00495 
00496     // call changed for all changed field containers after all values
00497     // are set
00498     for(std::vector<std::pair<FieldContainerPtr,BitVector> >::iterator cI=changedFCs.begin();
00499         cI != changedFCs.end();
00500         ++cI) 
00501     {
00502         changedCP(cI->first,cI->second);
00503         callChanged(cI->first);
00504     }
00505 
00506     // unregister mapper into factory
00507     factory->setMapper(NULL);
00508 
00509     if(_statistics)
00510     {
00511         _statistics->getElem(statSyncTime)->stop();
00512     }
00513 }

void RemoteAspect::sendSync ( Connection connection,
ChangeList changeList = NULL 
)

All changes from changeList are send to the connecteion except the fields which are filtered. Filters are used to avoid transmission of local states. e.g. GL variables.

Definition at line 519 of file OSGRemoteAspect.cpp.

References _aspectId, _fieldFilter, _mappedFC, _mappedType, _sendSyncFP, _sentFC, _statistics, ADDREFED, osg::ChangeList::beginAddRefd(), osg::ChangeList::beginChanged(), osg::ChangeList::beginCreated(), osg::ChangeList::beginDestroyed(), osg::ChangeList::beginSubRefd(), CHANGED, clearFCMapping(), CREATED, DESTROYED, osg::ChangeList::endAddRefd(), osg::ChangeList::endChanged(), osg::ChangeList::endCreated(), osg::ChangeList::endDestroyed(), osg::ChangeList::endSubRefd(), FDEBUG, osg::BinaryDataHandler::flush(), osg::FieldContainerFactory::getContainer(), osg::getContainerId(), osg::StatCollector::getElem(), handleFCMapping(), NEWTYPE, osg::NullFC, osg::BinaryDataHandler::putValue(), osg::ChangeList::sizeAddRefd(), osg::ChangeList::sizeCreated(), osg::ChangeList::sizeDestroyed(), osg::ChangeList::sizeSubRefd(), statSyncTime, SUBREFED, SYNCENDED, and osg::FieldContainerFactory::the().

Referenced by osg::ClusterWindow::frameInit().

00520 {
00521     ChangeList::changed_const_iterator  changedI;
00522     ChangeList::idrefd_const_iterator   createdI;
00523     ChangeList::idrefd_const_iterator   destroyedI;
00524     ChangeList::refd_const_iterator     addRefedI;
00525     ChangeList::refd_const_iterator     subRefedI;
00526     FieldFilterT::iterator              filterI;
00527     FieldContainerFactory               *fcFactory = FieldContainerFactory::the();
00528     FieldContainerPtr                   fcPtr;
00529     UInt32                              typeId;
00530     BitVector                           mask;
00531     UInt8                               cmd;
00532     std::string                         typeName;
00533     FieldMaskMapT::iterator             sentFCI;
00534     FieldMaskMapT                       changedMap;
00535     FieldMaskMapT::iterator             changedMapI;
00536     UInt32                              len;
00537 
00538     if(_statistics)
00539     {
00540         _statistics->getElem(statSyncTime)->start();
00541     }
00542 
00543     if(!changeList)
00544     {
00545         changeList = OSG::Thread::getCurrentChangeList();
00546     }
00547 
00548     // tell my aspect id
00549     connection.putValue(_aspectId);
00550 
00551     handleFCMapping(connection);
00552 
00553     Real64 progress_step = 0.0;
00554     Int32 progress = 0;
00555     if(_sendSyncFP != NULL)
00556         progress_step = 100.0 / Real64(changeList->sizeCreated());
00557 
00558     // created fct
00559     for(createdI = changeList->beginCreated();
00560         createdI != changeList->endCreated(); createdI++)
00561     {
00562         if(_sendSyncFP != NULL)
00563             _sendSyncFP("sending created objects", Int32(progress_step * Real64(++progress)));
00564 
00565         fcPtr = fcFactory->getContainer(*createdI);
00566         if(fcPtr == NullFC)
00567         {
00568             continue;
00569         }
00570 
00571         typeId = fcPtr->getTypeId();
00572 
00573         // type unknown by remote context ?
00574         if(_mappedType.count(typeId) == 0)
00575         {
00576             // mark type as known
00577             _mappedType.insert(typeId);
00578 
00579             // send new type
00580             cmd = NEWTYPE;
00581             typeName = fcPtr->getType().getName().str();
00582             connection.putValue(cmd);
00583             connection.putValue(typeId);
00584             connection.putValue(typeName);
00585         }
00586 
00587         cmd = CREATED;
00588         connection.putValue(cmd);
00589         connection.putValue(typeId);
00590         connection.putValue(*createdI);
00591 
00592         // sent container to create
00593         _sentFC.insert(*createdI);
00594         // fc is known by remote
00595         _mappedFC.insert(*createdI);
00596 
00597     }
00598 
00599     // changed fields
00600     // first create a condensed map, where each container is stored
00601     // only once
00602     for(changedI = changeList->beginChanged();
00603         changedI != changeList->endChanged(); 
00604         changedI++)
00605     {
00606         changedMapI = changedMap.find(changedI->first);
00607         if(changedMapI == changedMap.end())
00608         {
00609             changedMap.insert(std::pair < UInt32,
00610                                           BitVector > (changedI->first, changedI->second));
00611         }
00612         else
00613         {
00614             changedMapI->second |= changedI->second;
00615         }
00616     }
00617 
00618     progress = 0;
00619     if(_sendSyncFP != NULL)
00620         progress_step = 100.0 / Real64(changedMap.size());
00621 
00622     for(FieldMaskMapT::iterator condensedI = changedMap.begin();
00623         condensedI != changedMap.end();
00624         ++condensedI)
00625     {
00626         if(_sendSyncFP != NULL)
00627             _sendSyncFP("sending changed objects", Int32(progress_step * Real64(++progress)));
00628 
00629         if(_mappedFC.count(condensedI->first)==0)
00630             continue;
00631 
00632         FieldContainerPtr fcPtr = 
00633             FieldContainerFactory::the()->getContainer(condensedI->first);
00634 
00635         // ignore removed containers
00636         if(fcPtr == NullFC)
00637             continue;
00638         mask = condensedI->second;
00639 
00640         // apply field filter
00641         filterI = _fieldFilter.find(fcPtr->getType().getId());
00642         if(filterI != _fieldFilter.end())
00643         {
00644             FDEBUG(("SyncFieldFilter: :%s \n", 
00645                     fcPtr->getType().getName().str() )) 
00646             mask &= TypeTraits<BitVector>::BitsSet ^ filterI->second;
00647         }
00648 
00649         if(mask)
00650         {
00651             // send changes
00652             condensedI->second |= mask;
00653             cmd = CHANGED;
00654             connection.putValue(cmd);
00655             connection.putValue(condensedI->first); // id
00656             connection.putValue(mask);              // mask
00657             len = fcPtr->getBinSize(mask);
00658             connection.putValue(len);
00659             fcPtr->copyToBin(connection, mask);
00660             FDEBUG(("Changed: %s ID:%d Mask:%lld\n", 
00661                     fcPtr->getType().getName().str(),
00662                     getContainerId(fcPtr), 
00663                     mask))
00664         }
00665     }
00666 
00667     progress = 0;
00668     if(_sendSyncFP != NULL)
00669         progress_step = 100.0 / Real64(changeList->sizeDestroyed());
00670 
00671     // destroy fct
00672     // needs to be called after the changes (see receiveSync for more info)!!!
00673     for(destroyedI = changeList->beginDestroyed();
00674         destroyedI != changeList->endDestroyed(); destroyedI++)
00675     {
00676         if(_sendSyncFP != NULL)
00677             _sendSyncFP("sending destroyed objects", Int32(progress_step * Real64(++progress)));
00678 
00679         UInt32  id = (*destroyedI);
00680 
00681         // is it a known container
00682         if(_mappedFC.count(id))
00683         {
00684             clearFCMapping(id,0);
00685             cmd = DESTROYED;
00686             connection.putValue(cmd);
00687             connection.putValue(id);
00688         }
00689     }
00690 
00691     progress = 0;
00692     if(_sendSyncFP != NULL)
00693         progress_step = 100.0 / Real64(changeList->sizeAddRefd());
00694 
00695     // addref
00696     for(addRefedI = changeList->beginAddRefd();
00697         addRefedI != changeList->endAddRefd();
00698         ++addRefedI)
00699     {
00700         if(_sendSyncFP != NULL)
00701             _sendSyncFP("sending referenced objects", Int32(progress_step * Real64(++progress)));
00702 
00703         UInt32  id = (*addRefedI);
00704 
00705         if(_mappedFC.count(id)==0)
00706             continue;
00707         cmd = ADDREFED;
00708         connection.putValue(cmd);
00709         connection.putValue(id);
00710     }
00711 
00712     progress = 0;
00713     if(_sendSyncFP != NULL)
00714         progress_step = 100.0 / Real64(changeList->sizeSubRefd());
00715 
00716     // subref
00717     for(subRefedI = changeList->beginSubRefd();
00718         subRefedI != changeList->endSubRefd();
00719         ++subRefedI)
00720     {
00721         if(_sendSyncFP != NULL)
00722             _sendSyncFP("sending unreferenced objects", Int32(progress_step * Real64(++progress)));
00723 
00724         UInt32  id = (*subRefedI);
00725 
00726         // ignore addrefs for unknown fcs
00727         if(_mappedFC.count(id)==0)
00728             continue;
00729         cmd = SUBREFED;
00730         connection.putValue(cmd);
00731         connection.putValue(id);
00732     }
00733 
00734     cmd = SYNCENDED;
00735     connection.putValue(cmd);
00736 
00737     // write buffer
00738     connection.flush();
00739 
00740     if(_statistics)
00741     {
00742         _statistics->getElem(statSyncTime)->stop();
00743     }
00744 
00745     if(_sendSyncFP != NULL)
00746         _sendSyncFP("ready", 100);
00747 }

void RemoteAspect::registerCreated ( const FieldContainerType type,
const Functor func 
)

The given functor is called when a create of the specified type is received.

See also:
receiveSync

Definition at line 754 of file OSGRemoteAspect.cpp.

References _createdFunctors, _defaultCreatedFunction(), osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef().

00756 {
00757     while(type.getId() >= _createdFunctors.size())
00758     {
00759         _createdFunctors.push_back(
00760             osgTypedFunctionFunctor2CPtrRef
00761             <bool,FieldContainerPtr,RemoteAspect * >
00762             (&_defaultCreatedFunction));
00763     }
00764 
00765     _createdFunctors[type.getId()] = func;
00766 }

void RemoteAspect::registerDestroyed ( const FieldContainerType type,
const Functor func 
)

The given functor is called when a destroy of the specified type is received.

See also:
receiveSync

Definition at line 773 of file OSGRemoteAspect.cpp.

References _defaultDestroyedFunction(), _destroyedFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef().

00775 {
00776     while(type.getId() >= _destroyedFunctors.size())
00777     {
00778         _destroyedFunctors.push_back(osgTypedFunctionFunctor2CPtrRef < bool,
00779                                              FieldContainerPtr, RemoteAspect * > (&_defaultDestroyedFunction));
00780     }
00781 
00782     _destroyedFunctors[type.getId()] = func;
00783 }

void RemoteAspect::registerChanged ( const FieldContainerType type,
const Functor func 
)

The given functor is called when a change of the specified type is received.

See also:
receiveSync

Definition at line 790 of file OSGRemoteAspect.cpp.

References _changedFunctors, _defaultChangedFunction(), osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef().

Referenced by osg::ClusterServer::start().

00792 {
00793     while(type.getId() >= _changedFunctors.size())
00794     {
00795         _changedFunctors.push_back(osgTypedFunctionFunctor2CPtrRef < bool,
00796                                            FieldContainerPtr,
00797                                            RemoteAspect * > (&_defaultChangedFunction));
00798     }
00799 
00800     _changedFunctors[type.getId()] = func;
00801 }

void RemoteAspect::addFieldFilter ( UInt32  typeId,
BitVector  mask 
) [static]

add a new field filter. The given fieldmaks will not be transfered

Definition at line 805 of file OSGRemoteAspect.cpp.

References _fieldFilter.

Referenced by osg::SkyBackground::onCreate(), osg::SHLChunk::onCreate(), and osg::FBOViewport::onCreate().

00806 {
00807     _fieldFilter[typeId] |= mask;
00808 }

void RemoteAspect::subFieldFilter ( UInt32  typeId,
BitVector  mask 
) [static]

remove the filter for the given type and mask

Definition at line 812 of file OSGRemoteAspect.cpp.

References _fieldFilter.

00813 {
00814     _fieldFilter[typeId] &= ~mask;
00815 }

RemoteAspect::FieldFilterT const & RemoteAspect::getFieldFilter ( void   )  [static]

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 818 of file OSGRemoteAspect.cpp.

References _fieldFilter.

Referenced by osg::MultiDisplayWindow::updateViewport().

00819 {
00820     return _fieldFilter;
00821 }

BitVector RemoteAspect::getFieldFilter ( UInt32  typeId  )  [static]

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 824 of file OSGRemoteAspect.cpp.

References _fieldFilter.

00825 {
00826     FieldFilterT::const_iterator fI = _fieldFilter.find(typeId);
00827 
00828     if(fI != _fieldFilter.end())
00829     {
00830         return fI->second;
00831     }
00832     else
00833     {
00834         return TypeTraits<BitVector>::BitsClear;
00835     }
00836 }

void RemoteAspect::restoreChangeList ( ChangeList tocl  )  [static]

creates a changelist from the store and merges this to the changelist.

Definition at line 841 of file OSGRemoteAspect.cpp.

References _clStore, osg::ChangeList::addAddRefd(), osg::ChangeList::addChanged(), osg::ChangeList::addCreated(), osg::FieldBits::AllFields, osg::FieldContainerFactory::getContainer(), osg::NullFC, and osg::FieldContainerFactory::the().

00842 {
00843     for(clStoreIt i = _clStore.begin();i != _clStore.end(); ++i)
00844     {
00845         UInt32 id = (*i).first;
00846         FieldContainerPtr fc = FieldContainerFactory::the()->getContainer(id);
00847         if(fc != NullFC)
00848         {
00849             tocl->addCreated(id);
00850             for(UInt32 j=0;j<(*i).second;++j)
00851                 tocl->addAddRefd(fc);
00852             tocl->addChanged(fc, FieldBits::AllFields);
00853         }
00854     }
00855 }

void RemoteAspect::storeChangeList ( ChangeList cl  )  [static]

store all created, addRefd, subRefd, destroyed into the clStore.

Definition at line 859 of file OSGRemoteAspect.cpp.

References _clStore, osg::ChangeList::beginAddRefd(), osg::ChangeList::beginCreated(), osg::ChangeList::beginDestroyed(), osg::ChangeList::beginSubRefd(), osg::ChangeList::endAddRefd(), osg::ChangeList::endCreated(), osg::ChangeList::endDestroyed(), and osg::ChangeList::endSubRefd().

00860 {
00861     // created
00862     for(ChangeList::idrefd_const_iterator i = cl->beginCreated(); i != cl->endCreated(); ++i)
00863     {
00864         clStoreIt ci = _clStore.find(*i);
00865         if(ci == _clStore.end())
00866             _clStore.insert(std::pair<UInt32, UInt32>(*i, 0));
00867     }
00868 
00869     // addRef
00870     for(ChangeList::idrefd_const_iterator i = cl->beginAddRefd(); i != cl->endAddRefd(); ++i)
00871     {
00872         clStoreIt ci = _clStore.find(*i);
00873         if(ci != _clStore.end())
00874             (*ci).second++;
00875         //else
00876         //    FWARNING(("Called addRef on a not created fieldcontainer!\n"));
00877     }
00878     
00879     // subRef
00880     for(ChangeList::idrefd_const_iterator i = cl->beginSubRefd(); i != cl->endSubRefd(); ++i)
00881     {
00882         clStoreIt ci = _clStore.find(*i);
00883         if(ci != _clStore.end())
00884             (*ci).second--;
00885         //else
00886         //    FWARNING(("Called subRef on a not created fieldcontainer!\n"));
00887     }
00888     
00889     // destroyed
00890     for(ChangeList::idrefd_const_iterator i = cl->beginDestroyed(); i != cl->endDestroyed(); ++i)
00891     {
00892         clStoreIt ci = _clStore.find(*i);
00893         if(ci != _clStore.end())
00894             _clStore.erase(ci);
00895     }
00896 }

UInt32 RemoteAspect::getStoreSize ( void   )  [static]

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 898 of file OSGRemoteAspect.cpp.

References _clStore.

00899 {
00900     return _clStore.size();
00901 }

RemoteAspect::clStoreMap & RemoteAspect::getStore ( void   )  [static]

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 903 of file OSGRemoteAspect.cpp.

References _clStore.

00904 {
00905     return _clStore;
00906 }

void RemoteAspect::createCurrentStateChangeList ( const FieldContainerPtr start,
ChangeList cl 
) [static]

receiveSync reads changes from the given connection and applies them to the current thread aspect. Functors for registered types are called, if they occure in the sync stream.

See also:
registerCreated registerChanged registerDeleted

Definition at line 908 of file OSGRemoteAspect.cpp.

References osg::ChangeList::addAddRefd(), osg::ChangeList::addChanged(), osg::ChangeList::addCreated(), osg::FieldBits::AllFields, osg::ChangeList::clearAll(), osg::getContainerId(), osg::FieldContainerFactory::getFieldContainerStore(), osg::NullFC, and osg::FieldContainerFactory::the().

00910 {
00911     if(cl == NULL)
00912         return;
00913 
00914     cl->clearAll();
00915 
00916     typedef std::vector<FieldContainerPtr>::const_iterator  FCStoreConstIt;
00917 
00918     bool           foundStart = false;
00919     FCStoreConstIt fcIt       =
00920         FieldContainerFactory::the()->getFieldContainerStore()->begin();
00921     FCStoreConstIt fcEnd      =
00922         FieldContainerFactory::the()->getFieldContainerStore()->end  ();
00923 
00924     for(; fcIt != fcEnd; ++fcIt)
00925     {
00926         // skip destroyed FC
00927         if(*fcIt == NullFC)
00928             continue;
00929 
00930         // check for start here, in case someone uses a prototype as
00931         // start
00932         if(*fcIt == start)
00933             foundStart = true;
00934 
00935         // skip prototypes
00936         if((*fcIt)->getType().getPrototype() == NullFC ||
00937            (*fcIt)->getType().getPrototype() == (*fcIt)  )
00938         {
00939             continue;
00940         }
00941 
00942         if(foundStart == true)
00943         {
00944             cl->addCreated(getContainerId(*fcIt));
00945         
00946             for(UInt32 i = 0; i < (*fcIt).getRefCount(); ++i)
00947                 cl->addAddRefd(*fcIt);
00948 
00949             cl->addChanged(*fcIt, FieldBits::AllFields);
00950         }
00951     }
00952 }

void RemoteAspect::createCurrentStateChangeList ( ChangeList cl  )  [static]

Fills cl with change list entries so that it represents the current state of the system. For every FieldContainer cl will contain one Create entry, AddRefd entries to bring the ref count to its current value and one Changed entry that marks all fields as modified. All previous contents of cl are removed.

Definition at line 961 of file OSGRemoteAspect.cpp.

References osg::ChangeList::addAddRefd(), osg::ChangeList::addChanged(), osg::ChangeList::addCreated(), osg::FieldBits::AllFields, osg::ChangeList::clearAll(), osg::getContainerId(), osg::FieldContainerFactory::getFieldContainerStore(), osg::NullFC, and osg::FieldContainerFactory::the().

00962 {
00963     if(cl == NULL)
00964         return;
00965 
00966     cl->clearAll();
00967 
00968     typedef std::vector<FieldContainerPtr>::const_iterator  FCStoreConstIt;
00969 
00970     FCStoreConstIt fcIt =
00971         FieldContainerFactory::the()->getFieldContainerStore()->begin();
00972     FCStoreConstIt fcEnd =
00973         FieldContainerFactory::the()->getFieldContainerStore()->end  ();
00974 
00975     for(; fcIt != fcEnd; ++fcIt)
00976     {
00977         // skip destroyed FC
00978         if(*fcIt == NullFC)
00979             continue;
00980 
00981         // skip prototypes
00982         if((*fcIt)->getType().getPrototype() == NullFC ||
00983            (*fcIt)->getType().getPrototype() == (*fcIt)  )
00984         {
00985             continue;
00986         }
00987 
00988         cl->addCreated(getContainerId(*fcIt));
00989         
00990         for(UInt32 i = 0; i < (*fcIt).getRefCount(); ++i)
00991             cl->addAddRefd(*fcIt);
00992 
00993         cl->addChanged(*fcIt, FieldBits::AllFields);
00994     }
00995 }

void RemoteAspect::setStatistics ( StatCollector statistics  ) 

Set statistics collector

Definition at line 1002 of file OSGRemoteAspect.cpp.

References _statistics.

Referenced by osg::ClusterWindow::init(), and osg::ClusterWindow::setStatistics().

01003 {
01004     _statistics = statistics;
01005 }

void RemoteAspect::setSendSyncCB ( synccbfp  fp  ) 

Definition at line 1153 of file OSGRemoteAspect.cpp.

References _sendSyncFP.

01154 {
01155     _sendSyncFP = fp;
01156 }

bool RemoteAspect::callCreated ( FieldContainerPtr fcp  )  [protected]

Call created functor for a given FieldContainer

See also:
registerCreated

Definition at line 1014 of file OSGRemoteAspect.cpp.

References _createdFunctors, and _defaultCreatedFunction().

Referenced by receiveSync().

01015 {
01016     bool    result;
01017     UInt32  uiFunctorIndex = fcp->getType().getId();
01018 
01019     if(uiFunctorIndex < _createdFunctors.size())
01020     {
01021         result = _createdFunctors[uiFunctorIndex].call(fcp, this);
01022     }
01023     else
01024     {
01025         result = _defaultCreatedFunction(fcp, this);
01026     }
01027 
01028     return result;
01029 }

bool RemoteAspect::callDestroyed ( FieldContainerPtr fcp  )  [protected]

Call destroyed functor for a given FieldContainer

See also:
registerDestroyed

Definition at line 1035 of file OSGRemoteAspect.cpp.

References _defaultDestroyedFunction(), and _destroyedFunctors.

Referenced by receiveSync(), and ~RemoteAspect().

01036 {
01037     bool    result;
01038     UInt32  uiFunctorIndex = fcp->getType().getId();
01039 
01040     if(uiFunctorIndex < _destroyedFunctors.size())
01041     {
01042         result = _destroyedFunctors[uiFunctorIndex].call(fcp, this);
01043     }
01044     else
01045     {
01046         result = _defaultDestroyedFunction(fcp, this);
01047     }
01048 
01049     return result;
01050 }

bool RemoteAspect::callChanged ( FieldContainerPtr fcp  )  [protected]

Call changed functor for a given FieldContainer

See also:
registerChanged

Definition at line 1056 of file OSGRemoteAspect.cpp.

References _changedFunctors, and _defaultChangedFunction().

Referenced by receiveSync().

01057 {
01058     bool    result;
01059     UInt32  uiFunctorIndex = fcp->getType().getId();
01060 
01061     if(uiFunctorIndex < _changedFunctors.size())
01062     {
01063         result = _changedFunctors[uiFunctorIndex].call(fcp, this);
01064     }
01065     else
01066     {
01067         result = _defaultChangedFunction(fcp, this);
01068     }
01069 
01070     return result;
01071 }

void RemoteAspect::handleFCMapping ( Connection connection  )  [private]

This is called if a fc was edited that was created by another aspect

Definition at line 1076 of file OSGRemoteAspect.cpp.

References _mappedFC, _remoteFC, IDMAPPING, and osg::BinaryDataHandler::putValue().

Referenced by sendSync().

01077 {
01078     UInt8  cmd;
01079     UInt32 remoteId;
01080     UInt32 remoteAspect;
01081     RemoteFCMapT::iterator remoteFCI;
01082 
01083     for(remoteFCI = _remoteFC.begin() ;
01084         remoteFCI != _remoteFC.end() ;
01085         ++remoteFCI)
01086     {
01087         remoteId     = UInt32(remoteFCI->second);
01088         remoteAspect = UInt32(remoteFCI->second>>32);
01089 
01090         cmd = IDMAPPING;
01091         connection.putValue(cmd);
01092         connection.putValue(remoteFCI->first);
01093         connection.putValue(remoteAspect);
01094         connection.putValue(remoteId);
01095 
01096         _mappedFC.insert(remoteFCI->first);
01097     }
01098     _remoteFC.clear();
01099 }

void RemoteAspect::clearFCMapping ( UInt32  localId,
UInt32  remoteId 
) [private]

clear maps from local id

Definition at line 1103 of file OSGRemoteAspect.cpp.

References _localFC, _mappedFC, _receivedFC, _remoteFC, and _sentFC.

Referenced by receiveSync(), and sendSync().

01104 {
01105     _mappedFC.erase(localId);
01106     _sentFC.erase(localId);
01107     _receivedFC.erase(localId);
01108 
01109     if(!remoteId)
01110     {
01111         RemoteFCMapT::iterator remoteFCI=_remoteFC.find(localId);
01112         if(remoteFCI != _remoteFC.end())
01113             remoteId=static_cast<UInt32>(remoteFCI->second);
01114     }
01115     
01116     RemoteFCMapT::iterator remoteFCI=_remoteFC.find(localId);
01117     if(remoteFCI != _remoteFC.end())
01118         _remoteFC.erase(remoteFCI);
01119 
01120     LocalFCMapT::iterator localFCI=_localFC.find(remoteId);
01121     if(localFCI != _localFC.end())
01122         _localFC.erase(localFCI);
01123     
01124 }

bool RemoteAspect::getLocalId ( UInt32  remoteId,
UInt32 localId 
) [private]

get local id mapped from remote id

Definition at line 1128 of file OSGRemoteAspect.cpp.

References _localFC, and getFullRemoteId().

Referenced by receiveSync().

01130 {
01131     UInt64 fullRemoteId = getFullRemoteId(remoteId);
01132     LocalFCMapT::iterator localFCI=_localFC.find(fullRemoteId);
01133 
01134     if( localFCI != _localFC.end() )
01135     {
01136         localId=localFCI->second;
01137         return true;
01138     }
01139     else
01140     {
01141         return false;
01142     }
01143 }

UInt64 RemoteAspect::getFullRemoteId ( UInt32  remoteId  )  [private]

This is called if a fc was edited that was created by another aspect

Definition at line 1145 of file OSGRemoteAspect.cpp.

References _remoteAspectId.

Referenced by getLocalId(), osg::RemoteAspectFieldContainerMapper::map(), and receiveSync().

01146 {
01147     UInt64 remoteId=_remoteAspectId;
01148     remoteId<<=32;
01149     remoteId|=fcId;
01150     return remoteId;
01151 }

bool RemoteAspect::_defaultCreatedFunction ( FieldContainerPtr fcp,
RemoteAspect aspect 
) [static, private]

Default create functor

Definition at line 1169 of file OSGRemoteAspect.cpp.

References FDEBUG, and osg::getContainerId().

Referenced by callCreated(), and registerCreated().

01170 {
01171     FDEBUG(("Created:%s %d\n", 
01172             fcp->getType().getName().str(),
01173             getContainerId(fcp)))
01174     return true;
01175 }

bool RemoteAspect::_defaultDestroyedFunction ( FieldContainerPtr fcp,
RemoteAspect aspect 
) [static, private]

Default destroyed functor

Definition at line 1179 of file OSGRemoteAspect.cpp.

References FDEBUG, and osg::getContainerId().

Referenced by callDestroyed(), and registerDestroyed().

01181 {
01182     FDEBUG(("Destroyed:%s %d\n",
01183             fcp->getType().getName().str(),
01184             getContainerId(fcp)))
01185     return true;
01186 }

bool RemoteAspect::_defaultChangedFunction ( FieldContainerPtr fcp,
RemoteAspect aspect 
) [static, private]

Default changed functor

Definition at line 1190 of file OSGRemoteAspect.cpp.

References FDEBUG, and osg::getContainerId().

Referenced by callChanged(), and registerChanged().

01191 {
01192     FDEBUG(("Changed:%s %d\n", 
01193             fcp->getType().getName().str(),
01194             getContainerId(fcp)))
01195     return true;
01196 }

RemoteAspect& osg::RemoteAspect::operator= ( const RemoteAspect source  )  [private]

Friends And Related Function Documentation

friend class RemoteAspectFieldContainerMapper [friend]

Definition at line 242 of file OSGRemoteAspect.h.


Member Data Documentation

Definition at line 151 of file OSGRemoteAspect.h.

Referenced by receiveSync(), and sendSync().

Aspect id

Definition at line 169 of file OSGRemoteAspect.h.

Referenced by receiveSync(), and sendSync().

remote id to fieldcontainer mapping

Definition at line 172 of file OSGRemoteAspect.h.

Referenced by clearFCMapping(), getLocalId(), osg::RemoteAspectFieldContainerMapper::map(), and receiveSync().

local to remote fieldcontainer mapping

Definition at line 174 of file OSGRemoteAspect.h.

Referenced by clearFCMapping(), handleFCMapping(), and receiveSync().

remote typeid mapping

Definition at line 176 of file OSGRemoteAspect.h.

Referenced by receiveSync().

indicates fc was sent

Definition at line 179 of file OSGRemoteAspect.h.

Referenced by clearFCMapping(), and sendSync().

indicates fc was received

Definition at line 181 of file OSGRemoteAspect.h.

Referenced by clearFCMapping(), receiveSync(), and ~RemoteAspect().

indicates remote knows this fc

Definition at line 184 of file OSGRemoteAspect.h.

Referenced by clearFCMapping(), handleFCMapping(), and sendSync().

indicates mapped type

Definition at line 186 of file OSGRemoteAspect.h.

Referenced by sendSync().

Aspect id

Definition at line 188 of file OSGRemoteAspect.h.

Referenced by getFullRemoteId(), and receiveSync().

fild filter

Definition at line 196 of file OSGRemoteAspect.h.

Referenced by addFieldFilter(), getFieldFilter(), RemoteAspect(), sendSync(), and subFieldFilter().

std::vector<Functor> osg::RemoteAspect::_createdFunctors [protected]

Aspect id

Definition at line 197 of file OSGRemoteAspect.h.

Referenced by callCreated(), and registerCreated().

Aspect id

Definition at line 198 of file OSGRemoteAspect.h.

Referenced by callDestroyed(), and registerDestroyed().

std::vector<Functor> osg::RemoteAspect::_changedFunctors [protected]

Aspect id

Definition at line 199 of file OSGRemoteAspect.h.

Referenced by callChanged(), and registerChanged().

Aspect id

Definition at line 200 of file OSGRemoteAspect.h.

Referenced by receiveSync(), sendSync(), and setStatistics().

Aspect id

Definition at line 202 of file OSGRemoteAspect.h.

Referenced by sendSync(), and setSendSyncCB().

std::map< UInt32, UInt32 > RemoteAspect::_clStore [static, protected]

Aspect id

Definition at line 204 of file OSGRemoteAspect.h.

Referenced by getStore(), getStoreSize(), restoreChangeList(), and storeChangeList().


The documentation for this class was generated from the following files:

Generated on 8 Feb 2010 for OpenSG by  doxygen 1.6.1