ezEngine  Milestone 7
DataTransfer.h
1 #pragma once
2 
3 #include <CoreUtils/Basics.h>
4 #include <Foundation/Strings/String.h>
5 #include <Foundation/Communication/Telemetry.h>
6 #include <Foundation/Containers/Set.h>
7 
8 class EZ_COREUTILS_DLL ezDataTransfer;
9 
11 class EZ_COREUTILS_DLL ezDataTransferObject
12 {
13  EZ_DISALLOW_COPY_AND_ASSIGN(ezDataTransferObject);
14 
15 public:
30  ezDataTransferObject(ezDataTransfer& BelongsTo, const char* szObjectName, const char* szMimeType, const char* szFileExtension);
31 
34 
38  ezStreamWriterBase& GetWriter() { return m_Msg.GetWriter(); }
39 
41  void Transmit();
42 
43 private:
44  friend class ezDataTransfer;
45 
46  bool m_bHasBeenTransferred;
47  ezDataTransfer& m_BelongsTo;
48  ezTelemetryMessage m_Msg;
49 };
50 
74 class EZ_COREUTILS_DLL ezDataTransfer
75 {
76 public:
77 
80 
82  ~ezDataTransfer();
83 
85  void DisableDataTransfer();
86 
88  void EnableDataTransfer(const char* szDataName);
89 
91  void RequestDataTransfer();
92 
97  bool IsTransferRequested(bool bReset = true);
98 
99 private:
100  virtual void OnTransferRequest() { }
101 
102  void SendStatus();
103 
105  void Transfer(ezDataTransferObject& Object);
106 
107 private:
108  friend class ezDataTransferObject;
109 
110  static void TelemetryMessage(void* pPassThrough);
111  static void TelemetryEventsHandler(const ezTelemetry::TelemetryEventData& e);
112  static void Initialize();
113  static void SendAllDataTransfers();
114 
115  static bool s_bInitialized;
116 
117  bool m_bEnabled;
118  bool m_bTransferRequested;
119  ezString m_sDataName;
120  static ezSet<ezDataTransfer*> s_AllTransfers;
121 };