ezEngine  Milestone 7
ReloadableVariable.h
Go to the documentation of this file.
1 #pragma once
2 
4 
6 #include <Foundation/IO/MemoryStream.h>
7 #include <Foundation/Containers/Map.h>
8 #include <Foundation/Strings/String.h>
9 
29 #define EZ_MAKE_RELOADABLE(VarType, Variable) \
30  static ezReloadableVariableWrapper<VarType> EZ_CONCAT(g_ReloadableVar, EZ_SOURCE_LINE) (Variable, EZ_STRINGIZE(EZ_CONCAT(VarType, Variable)));
31 
32 
34 class EZ_FOUNDATION_DLL ezReloadableVariableBase : public ezEnumerable<ezReloadableVariableBase>
35 {
37 
38 public:
39  virtual ~ezReloadableVariableBase() { }
40 
42  static void StoreVariables();
43 
44 protected:
47 
49  static void RetrieveVariable(const char* szVarName, ezReloadableVariableBase* pVariable);
50 
51  const char* m_szVariableName;
52 
53 private:
54  EZ_DISALLOW_COPY_AND_ASSIGN(ezReloadableVariableBase);
55 
57  virtual void SaveState(ezStreamWriterBase& Stream) = 0;
59  virtual void LoadState(ezStreamReaderBase& Stream) = 0;
60 
63 };
64 
66 template<typename Type>
68 {
69 public:
70  ezReloadableVariableWrapper(Type& Variable, const char* szVarName);
71 
72 private:
73  EZ_DISALLOW_COPY_AND_ASSIGN(ezReloadableVariableWrapper);
74 
75  virtual void SaveState(ezStreamWriterBase& Stream) override;
76  virtual void LoadState(ezStreamReaderBase& Stream) override;
77 
78  Type& m_Variable;
79 };
80 
81 
82 #include <Foundation/Configuration/Implementation/ReloadableVariable_inl.h>
83