Emergency 20 Dokumentation  4.2.0
OperationMessageHandlerManager.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
15 
16 #include <boost/noncopyable.hpp>
17 
18 #include <memory>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Namespace ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  namespace multiplayer
27  {
28 
29 
30  //[-------------------------------------------------------]
31  //[ Classes ]
32  //[-------------------------------------------------------]
40  class EM5_API_EXPORT OperationMessageHandlerManager : public boost::noncopyable
41  {
42 
43 
44  //[-------------------------------------------------------]
45  //[ Public static methods ]
46  //[-------------------------------------------------------]
47  public:
48  static OperationMessageHandler* getHandlerById(OperationMessage id, bool onlyHost);
49  template <typename T> static T* getHandler(bool onlyHost);
50 
51 
52  //[-------------------------------------------------------]
53  //[ Public methods ]
54  //[-------------------------------------------------------]
55  public:
61 
67 
75  template <typename T> T* getHandler();
76 
87  inline OperationMessageHandler* getHandlerById(OperationMessage id);
88 
93  inline const std::map<OperationMessage, std::unique_ptr<OperationMessageHandler>>& getAllHandler() const;
94 
104  inline void registerHandler(OperationMessage id, OperationMessageHandler& operationMessageHandler);
105 
106 
107  //[-------------------------------------------------------]
108  //[ private data ]
109  //[-------------------------------------------------------]
110  private:
111  // TODO(ca) Please implement a std::hash template specialization for OperationMessage if you want to use an unordered_map with this key type (see <http://stackoverflow.com/questions/17885563/using-c11-unordered-set-in-visual-c-and-clang>)
112  //std::unordered_map<OperationMessage, std::unique_ptr<OperationMessageHandler>> mHandlerMap;
113  std::map<OperationMessage, std::unique_ptr<OperationMessageHandler>> mHandlerMap;
114 
115 
116  };
117 
118 
119 //[-------------------------------------------------------]
120 //[ Namespace ]
121 //[-------------------------------------------------------]
122  } // multiplayer
123 } // em5
124 
125 
126 //[-------------------------------------------------------]
127 //[ Implementation ]
128 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 base class for operation message handler.
Definition: OperationMessageHandler.h:46
#define EM5_API_EXPORT
Definition: Export.h:28
OperationMessage
EMERGENCY 5 multiplayer operation message types.
Definition: OperationMessages.h:51
EMERGENCY 5 Manager for operation message handler.
Definition: OperationMessageHandlerManager.h:40