MAK Legion 1.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
eventManager.h
Go to the documentation of this file.
1 /*********************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************************/
5 
8 
9 #pragma once
10 
11 #include "legionDataStore/export.h"
18 
19 #include <string>
20 #include <vector>
21 #include <functional>
22 #include <atomic>
23 
24 
25 namespace Legion
26 {
28 
29  typedef UInt64 EventManagerHandle;
30 
33  class LEGION_DLL EventManager
34  {
35  public:
37  template<typename EVENT_TYPE>
38  EVENT_TYPE createEvent();
39 
41  virtual EventManagerHandle handle() const;
42 
44  virtual UInt32 addEvent(const EventInstance& iEvent);
45 
47  virtual EventId registerEvent(const EventDescriptor& reg);
48 
50  virtual ParameterId parameterId(EventId eventId, const std::string& parameterName);
51 
55  template<typename EVENT_TYPE>
56  UInt32 addEventCallback(Callback<void(Span<EVENT_TYPE>&)> cb);
57 
58 
61  template<typename EVENT_TYPE>
62  bool removeEventCallback(UInt32 handle);
63 
64 
66  template<typename EVENT_TYPE>
67  const std::vector<const EVENT_TYPE> getEvents();
68 
69 
71  template<typename EVENT_TYPE>
72  const std::vector<EVENT_TYPE> peekEvents();
73 
75  virtual UInt32 nextId();
76 
77  virtual bool selfReflecting() const;
78  virtual void setSelfReflecting(bool val);
79 
80  virtual void addInterest(const EventId eventId);
81  virtual void removeInterest(const EventId eventId);
82 
83  protected:
86 
88  virtual ~EventManager();
89  friend class SimulationDatabase;
90 
91 
92  struct CallbackData
93  {
95  std::function<void(EventHandle* events, UInt32 count)> convertAndExecute;
96  };
97 
98  static void callback(void* usr, EventHandle* events, UInt32 count);
99  std::vector<CallbackData*> myCallbackData;
100 
101 
102  std::atomic<int> myNextId;
103 
105  };
106 }
107 
std::function< void(EventHandle *events, UInt32 count)> convertAndExecute
Definition: eventManager.h:95
UInt64 EventManagerHandle
Definition: eventManager.h:27
std::atomic< int > myNextId
Definition: eventManager.h:102
Defines a template callback object to make binding member function pointers easier.
The EventManager manages the creation and distribution of simulation events such as Fire and Detonate...
Definition: eventManager.h:33
An event descriptor describes the layout of an event.
Definition: eventDescriptor.h:43
A span represents a contiguous array of objects in memory.
Definition: span.h:22
Definition: eventManager.h:92
Callback template for binding static or member functions for callback at later time The return type a...
Definition: callback.h:66
An EventInstance is a single instance of a simulation event such as Fire or Detonate.
Definition: eventInstance.h:32
unsigned int UInt32
Definition: dataTypes.h:44
The SimulationDatabase stores all data for the simulation. It also owns the event, control, and view managers.
Definition: simulationDatabase.h:42
std::vector< CallbackData * > myCallbackData
Definition: eventManager.h:99
UInt64 EventHandle
Definition: eventInstance.h:22
UInt32 handle
Definition: eventManager.h:94
unsigned long long UInt64
Definition: dataTypes.h:46
UInt32 ParameterId
Definition: controlInstance.h:23
EventManagerHandle myHandle
Definition: eventManager.h:104
UInt32 EventId
Definition: eventInstance.h:20

Document ID: Generated on Wed May 26 15:17:05 EDT 2021 from SVN revision 229676
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)