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

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)