VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtAgentManagerInterface.h
Go to the documentation of this file.
00001 /****************************************************************************** 
00002 ** Copyright (c) 2010 MAK Technologies, Inc. 
00003 ** All rights reserved. 
00004 ******************************************************************************/ 
00005 /****************************************************************************** 
00006 ** $RCSfile: DtAgentManagerInterface.h,v $ $Revision: 1.23 $ $State: Exp $ 
00007 ******************************************************************************/ 
00008  
00012  
00013 #pragma once
00014 
00015 #include <vrvCore/vrvCore.h> 
00016 #include <vrvCore/DtUniqueID.h>
00017 #include <vrvUtil/DtMessage.h>
00018 
00019 #include <boost/signal.hpp>
00020 
00021 #include <list>
00022 #include <map>
00023 #include <string>
00024 #include <vector>
00025  
00026 namespace makVrv 
00027 {
00028    class DtMessage;
00029    class DtAgent;
00030    class DtAgentFactory;
00031 
00034    class DT_DLL_VRVCORE DtAgentManagerInterface 
00035    { 
00036    public:
00037       //The scene manager (typically will need to interact directly with
00039       friend class DtAgentManager;
00040 
00041       //Allow base Driver access to Master Scene, used to call protected functions.
00042       friend class DtAgent;
00043       
00046       static const double IgnoreSimulationTime;
00047 
00049       DtAgentManagerInterface(const DtAgentFactory* factory, 
00050          unsigned char myNamespaceId);
00051 
00053       virtual ~DtAgentManagerInterface();
00054 
00056       inline DtUniqueID createNewUniqueId()     
00057       {            
00058          ++myFreeID;
00059          //Clear most significant byte and place namespace id there.
00060          return (myFreeID & 0x00FFFFFFFFFFFFFFULL) | (myNamespaceId << 56);
00061       }
00062 
00064       static inline unsigned char namespaceFromUniqueId(DtUniqueID id)
00065       {         
00066          return (unsigned char) (id >> 56);
00067       }
00068 
00069       unsigned char namespaceId() const;
00070 
00072       inline bool uniqueIdFromAgentManagerInterface(const DtUniqueID& id) const
00073       {
00074          return namespaceId() == DtAgentManagerInterface::namespaceFromUniqueId(id);
00075       }
00076 
00079       inline unsigned int createNewCallID()
00080       {
00081          return ++myUpdateCallIndex;
00082       }
00083 
00086       virtual DtAgent* createNewObject(const std::string& objectClass, bool bDistribute);
00087 
00091       virtual void recreateObject(DtAgent* proxy);
00092 
00094       bool encodeUpdate( DtMessage& masterMsg, DtMessage& distributedMsg, double simulationTime );
00095 
00099       virtual void tick() = 0;
00100       
00101    protected:
00102 
00105       void deleteObject(DtAgent*);
00106 
00108       void queueObjectForUpdate(DtAgent* object);
00109 
00110    protected:
00111 
00112       struct IndexedMessage
00113       {
00114          unsigned int index;
00115          DtMessage message;
00116          bool distributeMessage;
00117 
00118          static inline bool sortCriteria(const IndexedMessage& a, const IndexedMessage& b)
00119          {
00120             return a.index < b.index;
00121          }
00122       };
00123       typedef std::list<IndexedMessage> OrderedCallList;
00124       
00126       typedef std::list<DtAgent*> AgentList;
00127 
00128       DtUniqueID myNamespaceId;
00129       DtUniqueID myFreeID;
00130       unsigned int myUpdateCallIndex;
00131       AgentList myUpdatedObjects;
00132       AgentList myToBeDeletedObjects;
00133       //Pointer to constant Driver Factory.
00134       const DtAgentFactory* myDriverFactory;
00135       OrderedCallList myMasterList;
00136    }; 
00137 } 

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)