VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtMessageMemberCall.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtMessageMemberCall.h,v $ $Revision: 1.20 $ $State: Exp $
7 ******************************************************************************/
8 
12 
13 #ifndef DtMessageMemberCall_H_
14 #define DtMessageMemberCall_H_
15 
16 #include <vrvCore/vrvCore.h>
17 #include <vrvUtil/DtMessage.h>
18 #include <vrvCore/DtAgentManager.h>
20 #include <vrvCore/DtAgent.h>
21 #include <vrvCore/DtDe.h>
22 #include <boost/type_traits.hpp>
23 
24 namespace makVrv
25 {
26 
27  template <typename T, bool isPointer,bool isDriver>
28  struct StorageType
29  {
30  typedef typename boost::remove_const<typename boost::remove_reference<T>::type>::type Result;
31  };
32 
33  template <typename T>
34  struct StorageType<T,true,true>
35  {
36  typedef DtUniqueID Result;
37  };
38 
39  template <class T>
40  struct CleanupType
41  {
42 
43  //Clean up T to make sure it is just the class.
44  typedef typename boost::remove_pointer<typename boost::remove_const<T>::type>::type TClass;
45 
46  enum { IsObject = boost::is_class<typename boost::remove_pointer<T>::type>::value};
47 
48  //Grab the Storage type of T, w/ T is a pointer & if T is a extends DtAgent.
50  };
51 
52 
53  template <typename DesiredType>
54  struct Cast
55  {
56  inline static DesiredType toFunctionType(DtDe&,DesiredType input)
57  {
58  return input;
59  }
60 
61  inline static DesiredType toFunctionType(DtDe& de,DtUniqueID input)
62  {
64  if(updater)
65  {
66  return (DesiredType)updater->objectMemoryAddress();
67  }
68  else
69  {
70  return 0;
71  }
72  }
73  };
74 
75  template <>
76  struct Cast<DtUniqueID>
77  {
78  inline static DtUniqueID toFunctionType(DtDe&,DtUniqueID input)
79  {
80  return input;
81  }
82  };
83 
86  template <class C>
88  {
89  public:
90  virtual void call(DtDe& de,C* c,DtMessage& msg) = 0;
91  };
92 
93 
95  template < class C>
97  {
98  public:
99  typedef void (C::*MemberFuncPtr)();
100 
102 
103  virtual void call(DtDe& de, C* c,DtMessage& msg)
104  {
105  try
106  {
107  (c->*myFunc)();
108  }
109  catch(DtException& ex)
110  {
111  de.DT_LOG_WARN << ex << std::endl;
112  }
113  catch(...)
114  {
115  de.DT_LOG_WARN << "Caught unknown exception" << std::endl;
116  }
117  }
119  };
120 
121  template <class C>
123  {
124  return new DtMessageMemberCall0<C>(m);
125  }
126 
127  //Define a Subclass of DtMessageMemberCall with N arguments.
128  #define DT_DEFINE_MESSAGE_MEMBER_CALL(argCount)\
129  template < class C, MAKE_LIST(typename T,argCount) >\
130  class DtMessageMemberCall##argCount : public DtMessageMemberCall<C>\
131  {\
132  public:\
133  typedef void (C::*MemberFuncPtr)( MAKE_LIST(T,argCount) );\
134  DtMessageMemberCall##argCount(MemberFuncPtr m) \
135  : myFunc(m)\
136  {\
137  }\
138  virtual void call(DtDe& de, C* c,DtMessage& msg)\
139  {\
140  MAKE_DECL_MULTILIST(typename CleanupType<T,>::Result a,argCount);\
141  msg >> MAKE_STREAMOUT(a,argCount);\
142  try\
143  {\
144  (c->*myFunc)(MAKE_CAST_CALL(Cast<T,>::toFunctionType,de,a,argCount));\
145  }\
146  catch(DtException& ex)\
147  {\
148  de.DT_LOG_WARN << ex << std::endl;\
149  }\
150  catch(...)\
151  {\
152  de.DT_LOG_WARN << "Caught unknown exception" << std::endl;\
153  }\
154  }\
155  MemberFuncPtr myFunc;\
156  };\
157  \
158  template <class C, MAKE_LIST(typename T,argCount) >\
159  DtMessageMemberCall<C>* bindMember(void (C::*m)( MAKE_LIST(T,argCount) ))\
160  {\
161  return new DtMessageMemberCall##argCount<C, MAKE_LIST(T,argCount) >(m);\
162  }
163 
173 
174 }
175 
176 #define DtMessageMemberCall_INL_
177 #include "DtMessageMemberCall.inl"
178 #undef DtMessageMemberCall_INL_
179 
180 #endif
181 
virtual void call(DtDe &de, C *c, DtMessage &msg)=0
MemberFuncPtr myFunc
Definition: DtMessageMemberCall.h:118
static DtUniqueID toFunctionType(DtDe &, DtUniqueID input)
Definition: DtMessageMemberCall.h:78
The IGI Message.
Definition: DtMessage.h:33
Abstract base class for object updaters.
Definition: DtAgentUpdateResolverInterface.h:23
Definition: DtMessageMemberCall.h:28
DtMessageMemberCall0(MemberFuncPtr m)
Definition: DtMessageMemberCall.h:101
DtMessageMemberCall< C > * bindMember(void(C::*m)())
Definition: DtMessageMemberCall.h:122
Contains makVrv::DtDe class.
StorageType< T, boost::is_pointer< T >::value, IsObject >::Result Result
Definition: DtMessageMemberCall.h:49
DtAgentManager & agentManager()
Get the scene manager.
#define DT_DEFINE_MESSAGE_MEMBER_CALL(argCount)
Definition: DtMessageMemberCall.h:128
DtUniqueID Result
Definition: DtMessageMemberCall.h:36
boost::remove_pointer< typename boost::remove_const< T >::type >::type TClass
Definition: DtMessageMemberCall.h:44
virtual DtAgentUpdateResolverInterface * findUpdater(DtUniqueID id)
Find the update handler for a particular object id.
Contains makVrv:DtAgentManager class.
void(C::* MemberFuncPtr)()
Definition: DtMessageMemberCall.h:99
Definition: DtMessageMemberCall.h:54
Special case for a function with zero arguments.
Definition: DtMessageMemberCall.h:96
virtual void call(DtDe &de, C *c, DtMessage &msg)
Definition: DtMessageMemberCall.h:103
static DesiredType toFunctionType(DtDe &, DesiredType input)
Definition: DtMessageMemberCall.h:56
unsigned long long DtUniqueID
Definition: DtUniqueID.h:22
Definition: DtMessageMemberCall.h:46
Contains makVrv:DtAgent class.
Abstract base class with wraps a member call with it&#39;s arguments stored in a message.
Definition: DtMessageMemberCall.h:87
Definition: DtMessageMemberCall.h:40
boost::remove_const< typename boost::remove_reference< T >::type >::type Result
Definition: DtMessageMemberCall.h:30
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
virtual void * objectMemoryAddress() const =0
Abstract getting the object memory address necessary for casting the ObjectType.
static DesiredType toFunctionType(DtDe &de, DtUniqueID input)
Definition: DtMessageMemberCall.h:61
Contains DLL export macros.

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)