Emergency 20 Dokumentation  4.2.0
DataPlayer.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 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
15 #include <qsf/job/JobProxy.h>
16 
17 #include <boost/function.hpp>
18 #include <boost/noncopyable.hpp>
19 
20 #include <iosfwd> // For the forward declarations of iostreams
21 #include <memory> // For std::unique_ptr
22 #include <string>
23 
24 
25 //[-------------------------------------------------------]
26 //[ Forward declarations ]
27 //[-------------------------------------------------------]
28 namespace qsf
29 {
30  namespace game
31  {
32  class BitStream;
33  }
34 }
35 
36 
37 //[-------------------------------------------------------]
38 //[ Namespace ]
39 //[-------------------------------------------------------]
40 namespace em5
41 {
42  namespace multiplayer
43  {
44 
45 
46  //[-------------------------------------------------------]
47  //[ Classes ]
48  //[-------------------------------------------------------]
53  class EM5_API_EXPORT DataPlayer : public boost::noncopyable
54  {
55 
56 
57  //[-------------------------------------------------------]
58  //[ Public definitions ]
59  //[-------------------------------------------------------]
60  public:
61  typedef boost::function<void(const qsf::game::BitStream& bitStream)> SendDataCallback;
62 
63 
64  //[-------------------------------------------------------]
65  //[ Public methods ]
66  //[-------------------------------------------------------]
67  public:
79  explicit DataPlayer(const uint32 updateJobId, const std::string& fileName, const SendDataCallback& sendDataCallback);
80 
85  virtual ~DataPlayer();
86 
91  void startup();
92 
93 
94  //[-------------------------------------------------------]
95  //[ Private definitions ]
96  //[-------------------------------------------------------]
97  private:
98  struct GameRecord
99  {
100  int64 mTime;
101  size_t mExtraBitCount;
102  std::vector<uint8> mData;
103  };
104 
105 
106  //[-------------------------------------------------------]
107  //[ Private methods ]
108  //[-------------------------------------------------------]
109  private:
110  void onUpdateTick(const qsf::JobArguments& jobArguments);
111  bool readNextGameRecordFromFile();
112  void sendDataToClient();
113 
114 
115  //[-------------------------------------------------------]
116  //[ Private data ]
117  //[-------------------------------------------------------]
118  private:
119  std::unique_ptr<std::istream> mPlayerStream;
120  std::string mFilename;
121  GameRecord mNextGameRecord;
122  SendDataCallback mSendDataCallback;
123  const uint32 mUpdateJobId;
124 
125  qsf::JobProxy mPlayDataJobProxy;
126 
127 
128  };
129 
130 
131 //[-------------------------------------------------------]
132 //[ Namespace ]
133 //[-------------------------------------------------------]
134  } // multiplayer
135 } // em5
Definition: ActionPriority.h:13
boost::function< void(const qsf::game::BitStream &bitStream)> SendDataCallback
Definition: DataPlayer.h:61
Job proxy class.
Definition: JobProxy.h:51
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Definition: PickupPersonByParamedicAction.h:21
int64_t int64
Definition: PlatformTypes.h:183
EMERGENCY 5 multiplayer data player. Plays back any data recorded by the data recorder.
Definition: DataPlayer.h:53