VR-Forces Developer's Guide
 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 ~DtMessageMemberCall() {}
88  virtual void call(DtDe& de,C* c,DtMessage& msg) = 0;
89  };
90 
91 
93  template < class C>
95  {
96  public:
97  typedef void (C::*MemberFuncPtr)();
98 
101 
102  virtual void call(DtDe& de, C* c,DtMessage& msg)
103  {
104  try
105  {
106  (c->*myFunc)();
107  }
108  catch(DtException& ex)
109  {
110  de.DT_LOG_WARN << ex << std::endl;
111  }
112  catch(...)
113  {
114  de.DT_LOG_WARN << "Caught unknown exception" << std::endl;
115  }
116  }
118  };
119 
120  template <class C>
122  {
123  return new DtMessageMemberCall0<C>(m);
124  }
125 
126  //Define a Subclass of DtMessageMemberCall with N arguments.
127  #define DT_DEFINE_MESSAGE_MEMBER_CALL(argCount)\
128  template < class C, MAKE_LIST(typename T,argCount) >\
129  class DtMessageMemberCall##argCount : public DtMessageMemberCall<C>\
130  {\
131  public:\
132  typedef void (C::*MemberFuncPtr)( MAKE_LIST(T,argCount) );\
133  DtMessageMemberCall##argCount(MemberFuncPtr m) \
134  : myFunc(m)\
135  {\
136  }\
137  virtual void call(DtDe& de, C* c,DtMessage& msg)\
138  {\
139  MAKE_DECL_MULTILIST(typename CleanupType<T,>::Result a,argCount);\
140  msg >> MAKE_STREAMOUT(a,argCount);\
141  try\
142  {\
143  (c->*myFunc)(MAKE_CAST_CALL(Cast<T,>::toFunctionType,de,a,argCount));\
144  }\
145  catch(DtException& ex)\
146  {\
147  de.DT_LOG_WARN << ex << std::endl;\
148  }\
149  catch(...)\
150  {\
151  de.DT_LOG_WARN << "Caught unknown exception" << std::endl;\
152  }\
153  }\
154  MemberFuncPtr myFunc;\
155  };\
156  \
157  template <class C, MAKE_LIST(typename T,argCount) >\
158  DtMessageMemberCall<C>* bindMember(void (C::*m)( MAKE_LIST(T,argCount) ))\
159  {\
160  return new DtMessageMemberCall##argCount<C, MAKE_LIST(T,argCount) >(m);\
161  }
162 
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:117
static DtUniqueID toFunctionType(DtDe &, DtUniqueID input)
Definition: DtMessageMemberCall.h:75
The IGI Message. Is easily encoded and decoding using stream operators. It also provides validation d...
Definition: DtMessage.h:30
Abstract base class for object updaters.
Definition: DtAgentUpdateResolverInterface.h:20
Definition: DtMessageMemberCall.h:25
DtMessageMemberCall0(MemberFuncPtr m)
Definition: DtMessageMemberCall.h:99
DtMessageMemberCall< C > * bindMember(void(C::*m)())
Definition: DtMessageMemberCall.h:121
Contains makVrv::DtDe class.
Definition: DtMessageMemberCall.h:43
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:127
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:97
Definition: DtMessageMemberCall.h:51
Special case for a function with zero arguments.
Definition: DtMessageMemberCall.h:94
virtual ~DtMessageMemberCall0()
Definition: DtMessageMemberCall.h:100
virtual void call(DtDe &de, C *c, DtMessage &msg)
Definition: DtMessageMemberCall.h:102
static DesiredType toFunctionType(DtDe &, DesiredType input)
Definition: DtMessageMemberCall.h:53
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
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. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
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
virtual ~DtMessageMemberCall()
Definition: DtMessageMemberCall.h:87
Contains DLL export macros.

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)