Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGRemoteAspect.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 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 #ifndef _REMOTEASPECT_H_
00041 #define _REMOTEASPECT_H_
00042 #ifdef __sgi
00043 #pragma once
00044 #endif
00045 
00046 #include <map>
00047 #include <set>
00048 #include <OSGSystemDef.h>
00049 #include <OSGBaseTypes.h>
00050 #include <OSGFieldContainerPtr.h>
00051 #include <OSGFieldContainerFactory.h>
00052 #include <OSGChangeList.h>
00053 #include <OSGConnection.h>
00054 #include <OSGTypedFunctors.h>
00055 #include <OSGStatCollector.h>
00056 #include <OSGStatElemTypes.h>
00057 
00058 OSG_BEGIN_NAMESPACE
00059 
00060 class OSG_SYSTEMLIB_DLLMAPPING RemoteAspect
00061 { 
00062     /*==========================  PUBLIC  =================================*/
00063   public:
00065     enum DataTypes 
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     };
00076 
00078     typedef ArgsCollector<RemoteAspect *> FunctorArgs;
00079     typedef TypedFunctor2Base<bool, 
00080                               CPtrRefCallArg<FieldContainerPtr>, 
00081                               FunctorArgs                      > Functor;
00082 
00084     typedef std::map<UInt64,UInt32>    LocalFCMapT;
00086     typedef std::map<UInt32,UInt64>    RemoteFCMapT;
00088     typedef std::map<UInt32,UInt32>    LocalTypeMapT;
00089 
00091     typedef std::set<UInt32>           IdSetT;
00092 
00094     typedef std::map<UInt32,BitVector> FieldFilterT;
00095     typedef std::map<UInt32,BitVector> FieldMaskMapT;
00096 
00097     /*---------------------------------------------------------------------*/
00101     RemoteAspect(UInt32 aspectId=0);
00102     virtual ~RemoteAspect(void); 
00103 
00105     /*---------------------------------------------------------------------*/
00109     void receiveSync      ( Connection &connection,
00110                             bool applyToChangelist=false   );
00111     void sendSync         ( Connection &connection,
00112                             ChangeList *changeList=NULL    );
00113     void registerCreated  ( const FieldContainerType &type, 
00114                             const Functor &func            );
00115     void registerDestroyed( const FieldContainerType &type, 
00116                             const Functor &func            );
00117     void registerChanged  ( const FieldContainerType &type, 
00118                             const Functor &func            );
00119     static void addFieldFilter   ( UInt32 typeId,BitVector mask   );
00120     static void subFieldFilter   ( UInt32 typeId,BitVector mask   );
00121     
00122     static void restoreChangeList   (ChangeList *tocl);
00123     static void storeChangeList     (ChangeList *cl  );
00124     static UInt32 getStoreSize      (void            );
00125 
00126     typedef std::map<UInt32, UInt32> clStoreMap;
00127     typedef clStoreMap::iterator clStoreIt;
00128     static clStoreMap &getStore     (void            );
00129 
00131     /*---------------------------------------------------------------------*/
00135     void setStatistics( StatCollector * stat );
00136 
00139     /*=========================  PROTECTED  ===============================*/
00140   protected:
00141     /*---------------------------------------------------------------------*/
00146     UInt32                            _aspectId;
00147 
00149     LocalFCMapT                       _localFC;
00151     RemoteFCMapT                      _remoteFC;
00153     LocalTypeMapT                     _localType;
00154 
00156     IdSetT                            _sentFC;
00158     IdSetT                            _receivedFC;
00159 
00161     IdSetT                            _mappedFC;
00163     IdSetT                            _mappedType;
00164 
00165     UInt32                            _remoteAspectId;
00166 
00167 #if 0
00168 
00169     std::map<UInt32,BitVector>        _sentFC;
00170 #endif
00171 
00173     static FieldFilterT               _fieldFilter;
00174     std::vector<Functor>              _createdFunctors;
00175     std::vector<Functor>              _destroyedFunctors;
00176     std::vector<Functor>              _changedFunctors;
00177     StatCollector                    *_statistics;
00178 
00179     static std::map<UInt32, UInt32>   _clStore;
00180     
00182     /*---------------------------------------------------------------------*/
00186     bool   callCreated   ( FieldContainerPtr &node   );
00187     bool   callDestroyed ( FieldContainerPtr &node   );
00188     bool   callChanged   ( FieldContainerPtr &node   );
00189 
00192     /*==========================  PRIVATE  ================================*/
00193   private:
00194     /*---------------------------------------------------------------------*/
00198     void handleFCMapping   (Connection &connection               );
00199     void clearFCMapping    (UInt32 localId,UInt32 remoteId       );
00200     bool getLocalId        (UInt32  remoteId,
00201                             UInt32 &localId                      );
00202     UInt64 getFullRemoteId (UInt32  remoteId                     );
00203 
00205     /*---------------------------------------------------------------------*/
00208     static bool _defaultCreatedFunction  (FieldContainerPtr& fcp,
00209                                           RemoteAspect * aspect);
00210     static bool _defaultDestroyedFunction(FieldContainerPtr& fcp,
00211                                           RemoteAspect * aspect);
00212     static bool _defaultChangedFunction  (FieldContainerPtr& fcp,
00213                                           RemoteAspect * aspect);
00214 
00215     static StatElemDesc<StatTimeElem> statSyncTime;
00218     friend class RemoteAspectFieldContainerMapper;
00219     // prohibit default functions (move to 'public' if you need one)
00220     RemoteAspect(const RemoteAspect &source);
00221     RemoteAspect &operator =(const RemoteAspect &source);
00222 };
00223 
00224 // class pointer
00225 typedef RemoteAspect *RemoteAspectP;
00226 
00227 struct RemoteAspectFieldContainerMapper:public FieldContainerMapper
00228 {                                              
00229     virtual UInt32 map(UInt32 uiId);
00230     RemoteAspect *_remoteAspect;
00231 };
00232 
00233 OSG_END_NAMESPACE
00234 
00235 #define OSGREMOTEASPECT_HEADER_CVSID "@(#)$Id:$"
00236 
00237 #endif /* _REMOTEASPECT_H_ */

Generated on Thu Aug 25 04:09:07 2005 for OpenSG by  doxygen 1.4.3