VR-Forces 4.0.4 Class Documentation
include/vrvCore/DtAgent.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2010 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: DtAgent.h,v $ $Revision: 1.18 $ $State: Exp $
00007 ******************************************************************************/
00008 
00012 
00013 #pragma once
00014 
00015 #include <vrvCore/vrvCore.h>
00016 #include <vrvCore/DtAgentManagerInterface.h>
00017 #include <vrvCore/DtAgentManager.h>
00018 #include <vrvUtil/templateUtil.h>
00019 
00020 
00021 #include <boost/type_traits.hpp>
00022 #include <map>
00023 #include <string>
00024 #include <list>
00025 
00026 namespace makVrv
00027 {  
00028    template <typename T,bool>
00029    struct ArgOverrideAsId;
00030      
00031    template <typename T>
00032    struct ArgOverrideAsId<T,false>
00033    {
00034       typedef T Type;
00035    };
00036 
00037    template <typename T>
00038    struct ArgOverrideAsId<T,true>
00039    {
00040       typedef DtUniqueID Type;
00041    };
00042 
00045    template <typename T>
00046    struct Arg
00047    {
00048       typedef typename ArgOverrideAsId<T,boost::is_pointer<T>::value && 
00049          boost::is_class<typename boost::remove_pointer<T>::type >::value>::Type Type;
00050    };
00051 
00052 
00053 
00056    class DT_DLL_VRVCORE DtAgent
00057    {
00058    public:    
00059 
00061       friend class DtAgentManagerInterface;
00062       friend class DtAgentManager;
00063 
00065       virtual ~DtAgent();
00066 
00069       inline DtAgentManagerInterface& sceneInterface();
00070 
00072       inline void setSceneInterface(DtAgentManagerInterface* iface);      
00073 
00076       void init(DtAgentManagerInterface& sceneInterface, bool bDistribute);
00077 
00079       inline const std::string& className() const;
00080 
00081       //Makes the object clean, it will not generate an update.
00082       inline void clean();
00083 
00084       //Makes the object dirty, indicating that it will be checked for an update
00085       inline void dirty();
00086 
00088       inline DtUniqueID uniqueId() const;
00089 
00092       inline bool distributeMessages() const;
00093 
00094    protected:
00095 
00097       inline DtMessage& startNewCall(unsigned int function);
00098 
00100       void addCreateObjectCall();
00101 
00103       void addDeleteObjectCall();
00104 
00106       inline unsigned int callCount() const;
00107 
00108       //This declares a template function for queuing a single operation call with N arguments
00111       #define DT_DECLARE_QUEUE_OPERATION_FUNCTION(argCount)\
00112       template <typename C, MAKE_LIST(typename T,argCount) >\
00113       inline void queueOperationCall(unsigned int state_function,\
00114          void (C::*m)( MAKE_LIST(T,argCount) ),\
00115          MAKE_MULTILIST(typename Arg<T,>::Type t,argCount));
00116 
00117       //No arguments are a special case
00118       template <typename C>
00119       inline void queueOperationCall(unsigned int state_function, void (C::*m)());
00120 
00123       DT_DECLARE_QUEUE_OPERATION_FUNCTION(1)
00124       DT_DECLARE_QUEUE_OPERATION_FUNCTION(2)
00125       DT_DECLARE_QUEUE_OPERATION_FUNCTION(3)
00126       DT_DECLARE_QUEUE_OPERATION_FUNCTION(4)
00127       DT_DECLARE_QUEUE_OPERATION_FUNCTION(5)
00128       DT_DECLARE_QUEUE_OPERATION_FUNCTION(6)
00129       DT_DECLARE_QUEUE_OPERATION_FUNCTION(7)
00130       DT_DECLARE_QUEUE_OPERATION_FUNCTION(8)
00131       DT_DECLARE_QUEUE_OPERATION_FUNCTION(9)
00132 
00133    protected:
00134       
00136       DtAgent(/* Do not add parameters here. Add them to init(). */);
00137 
00139       DtAgent(DtAgent&);
00140 
00142       inline DtAgentManagerInterface::OrderedCallList& callList();
00143 
00144    protected:
00145 
00146       DtAgentManagerInterface* mySceneInterface;
00147       DtUniqueID myUniqueId;
00148       std::string myClassName;
00149       bool myUpdateFlag;
00150       DtAgentManagerInterface::OrderedCallList myCalls;
00151       bool myDistributeObjectFlag;
00152    };
00153    
00154 }
00155 
00156 #define DtAgent_INL_ 
00157 #include "DtAgent.inl"
00158 #undef DtAgent_INL_ 

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)