VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
interactionEvent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
9 #include <vrfutil/rwUUID.h>
10 
11 class DtInteraction;
12 
13 //
14 // class DtInteractionEvent
15 //
16 // This template class can be used to wrap any subclass of the VR-Link DtInteraction class. The
17 // interaction can then be passed between the simulation and network threads for sending and
18 // receiving.
19 template <typename T_Interaction, unsigned EventId>
21 {
22 public:
23 
24  typedef void(*CallbackFcn)(const DtInteractionEvent<T_Interaction, EventId>*, void* usr);
25 
27  DtInteractionEvent(const DtUUID& sender, const T_Interaction& inter);
30 
31  virtual ~DtInteractionEvent();
32 
33  virtual void setInteraction(const T_Interaction& inter);
34  const T_Interaction& interaction() const;
35 
36  virtual void setSenderId(const DtUUID& sender);
37  const DtUUID& senderId() const;
38 
39  virtual makVrfEvents::DtEvent* clone() const { return new DtInteractionEvent(*this); };
40 
41 protected:
43  T_Interaction myInteraction;
44 };
45 
46 template <typename T_Interaction, unsigned EventId>
48  : makVrfEvents::DtEvent(static_cast<makVrfEvents::DtEvent::EventType>(EventId))
49  , mySender(DtUUID::nullUUID())
50  , myInteraction()
51 {
52 }
53 
54 template <typename T_Interaction, unsigned EventId>
56  const DtUUID& sender, const T_Interaction& inter)
57  : makVrfEvents::DtEvent(static_cast<makVrfEvents::DtEvent::EventType>(EventId))
58  , mySender(sender)
59  , myInteraction(inter)
60 {
61 }
62 
63 template <typename T_Interaction, unsigned EventId>
66  : makVrfEvents::DtEvent(orig)
67  , mySender(orig.mySender)
68  , myInteraction(orig.myInteraction)
69 {
70 }
71 
72 template <typename T_Interaction, unsigned EventId>
75 {
77 
78  myInteraction = rhs.myInteraction;
79  mySender = rhs.mySender;
80 
81  return *this;
82 }
83 
84 template <typename T_Interaction, unsigned EventId>
86 {
87 }
88 
89 template <typename T_Interaction, unsigned EventId>
91 {
92  myInteraction = inter;
93 }
94 
95 template <typename T_Interaction, unsigned EventId>
97 {
98  return myInteraction;
99 }
100 
101 template <typename T_Interaction, unsigned EventId>
103 {
104  mySender = sender;
105 }
106 
107 template <typename T_Interaction, unsigned EventId>
109 {
110  return mySender;
111 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
EventType
Definition: event.h:16
DtInteractionEvent & operator=(const DtInteractionEvent &)
Definition: interactionEvent.h:73
virtual void setInteraction(const T_Interaction &inter)
Definition: interactionEvent.h:90
Contains the DtUUID class declaration.
DtInteractionEvent()
Definition: interactionEvent.h:47
const DtUUID & senderId() const
Definition: interactionEvent.h:108
DtUUID mySender
Definition: interactionEvent.h:39
void(* CallbackFcn)(const DtInteractionEvent< T_Interaction, EventId > *, void *usr)
Definition: interactionEvent.h:24
T_Interaction myInteraction
Definition: interactionEvent.h:43
Definition: event.h:13
virtual void setSenderId(const DtUUID &sender)
Definition: interactionEvent.h:102
DtEvent & operator=(const DtEvent &)
virtual ~DtInteractionEvent()
Definition: interactionEvent.h:85
const T_Interaction & interaction() const
Definition: interactionEvent.h:96
Definition: interactionEvent.h:20
virtual makVrfEvents::DtEvent * clone() const
Definition: interactionEvent.h:39

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)