VR-Forces 4.0.4 Class Documentation
include/vrvVrl/DtEntitySimDataProcessor.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2009 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: DtVrlinkEntitySimDataProcessor.h,v $ $Revision: 1.12 $ $State: Exp $
00007 ******************************************************************************/
00008 
00012 
00013 #ifndef DtVrlinkEntitySimDataProcessor_H_
00014 #define DtVrlinkEntitySimDataProcessor_H_
00015 
00016 #include <vrvVrl/vrvVrl.h>
00017 #include <vrvCore/DtSimDataProcessorInterface.h>
00018 #include <vrvCore/DtEntityState.h>
00019 #include <vrvCore/DtSimEntryUpdater.h>
00020 #include <vrvUtil/DtBalancedUpdater.h>
00021 #include <vrvUtil/DtSignalConnectionManager.h>
00022 
00023 #include <vlutil/vlPerformanceStats.h>
00024 
00025 #include <boost/bind.hpp>
00026 
00027 #ifndef DT_PROTOCOL_NAMESPACE
00028 #error Namespace Protocol Macro DT_PROTOCOL_NAMESPACE not defined.
00029 #endif
00030 
00031 namespace makVrv
00032 {
00033    class DtEntityStateObjectAgent;
00034    class DtSimEntryObjectAgent;
00035    class DtEntityStateListener;
00036 
00037    namespace DT_PROTOCOL_NAMESPACE
00038    {
00039       class DtEntityExistenceListener;
00040       class DtVrlinkEntityStateListener;
00041 
00044       class DL_DLL_IGCONVRLINK DtEntitySimDataProcessor : public DtSimDataProcessorInterface
00045       {
00046       public:
00047 
00049          static DtEntitySimDataProcessor* findInstance(DtVrlinkConnection& sim);
00050 
00052          static void registerInstance(DtVrlinkConnection& sim,DtEntitySimDataProcessor*);
00053 
00055          DtEntitySimDataProcessor(DtVrlinkConnection& sim);
00056 
00058          virtual ~DtEntitySimDataProcessor();
00059          
00061          void postDrainInput();
00062 
00064          void setObjectUpdateRate(DtUniqueID uniqueId, DtSimEntryUpdater::UpdateRate rate);
00065 
00067          void forceObjectUpdate(DtUniqueID uniqueId);
00068 
00070          void entityDiscovered(DtVrlinkEntityStateListener& listener);
00071 
00073          void entityToBeDeleted(DtEntityStateListener& listener);
00074 
00076          virtual void createAndSendState(DtEntityStateListener& listener,
00077             DtEntityStateObjectAgent& objectDriver);
00078 
00079       protected:
00080 
00082          static void postDrainInput(void* usr);
00083          virtual void slot_postUpdateCallback(DtEntityStateListener&);
00084          virtual void setState(DtVrlinkEntityStateListener& listener, DtVrlinkSimulatedEntityState& state);
00085 
00086       protected:
00087          
00088          //A Listener and a driver which will be updated with it.
00089          class EntityStateUpdater
00090          {
00091          public:
00092 
00093             EntityStateUpdater(DtEntityStateListener& listener,
00094                DtEntityStateObjectAgent& driver, DtEntitySimDataProcessor& processor);
00095 
00096             EntityStateUpdater(const EntityStateUpdater& orig);
00097 
00098             EntityStateUpdater& operator=(const EntityStateUpdater& orig);
00099 
00100             //Are the updaters equal
00101             bool operator==(const EntityStateUpdater& orig) const;
00102 
00104             void update(double timeT);
00105 
00106          protected:
00107 
00108             DtEntityStateListener* myListener;
00109             DtEntityStateObjectAgent* myObjectAgent;
00110             DtEntitySimDataProcessor* myProcessor;
00111          };
00112     
00113          typedef std::vector<DtUniqueID> EntityIdList;
00114 
00115          struct EntitySimDataInstance
00116          {
00117             DtEntityStateListener* myListener;
00118             DtEntityStateObjectAgent* myAgent;
00119             DtSimEntryUpdater::UpdateRate myRate;
00120          };
00121 
00122          typedef std::map<DtUniqueID,EntitySimDataInstance > EntityAgentMap;
00123 
00124          typedef DtBalancedUpdater<EntityStateUpdater> EntityUpdaterGroup;
00125          typedef std::map<DtSimEntryUpdater::UpdateRate,EntityUpdaterGroup>
00126             EntityUpdateGroupMap;                  
00127 
00128       protected:
00129 
00130          DtSignalConnectionManager myConnections;
00131 
00132          DtVrlinkConnection& mySimulation;
00133          DtEntityExistenceListener& myListener;
00134          DtTimedSection myTimer;
00135          DtSimEntryObjectAgent* mySimEntryAgent;
00136 
00137          EntityAgentMap myEntityAgents;
00138          EntityUpdateGroupMap myRefreshRateGroups;
00139          EntityIdList myForceUpdateList;
00140          
00141       };
00142    }
00143 }
00144 
00145 #endif
00146 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)