Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef SHARED_REPLAYCONTEXT_H
  5. #define SHARED_REPLAYCONTEXT_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "baserecordingsessionmanager.h"
  11. #include "baserecordingsessionblockmanager.h"
  12. #include "errorsystem.h"
  13. //----------------------------------------------------------------------------------------
  14. class CBaseRecordingSessionManager;
  15. class CBaseRecordingSessionBlockManager;
  16. class CErrorSystem;
  17. class IThreadPool;
  18. //----------------------------------------------------------------------------------------
  19. class CSharedReplayContext
  20. {
  21. public:
  22. CSharedReplayContext( IReplayContext *pOwnerContext );
  23. virtual ~CSharedReplayContext();
  24. // Sets up public data members and such
  25. virtual bool Init( CreateInterfaceFn fnFactory );
  26. virtual void Shutdown();
  27. virtual void Think();
  28. virtual bool IsInitialized() const { return m_bInit; }
  29. virtual const char *GetRelativeBaseDir() const;
  30. virtual const char *GetBaseDir() const;
  31. virtual const char *GetReplaySubDir() const;
  32. IThreadPool *m_pThreadPool;
  33. CBaseRecordingSessionManager *m_pRecordingSessionManager;
  34. CBaseRecordingSessionBlockManager *m_pRecordingSessionBlockManager;
  35. CErrorSystem *m_pErrorSystem;
  36. CUtlString m_strRelativeBasePath; // eg: "/replay/server/"
  37. CUtlString m_strBasePath; // eg: "/user/home/tfadmin/tf/replay/server/"
  38. CUtlString m_strSubDir; // "client" or "server"
  39. bool m_bInit; // Initialized yet? Set by outer class.
  40. private:
  41. bool InitThreadPool();
  42. void EnsureDirHierarchy();
  43. IReplayContext *m_pOwnerContext;
  44. };
  45. //----------------------------------------------------------------------------------------
  46. #define LINK_TO_SHARED_REPLAYCONTEXT_IMP() \
  47. CSharedReplayContext *m_pShared; \
  48. virtual bool IsInitialized() const { return m_pShared && m_pShared->IsInitialized(); } \
  49. virtual const char *GetRelativeBaseDir() const { return m_pShared->GetRelativeBaseDir(); } \
  50. virtual const char *GetBaseDir() const { return m_pShared->GetBaseDir(); } \
  51. virtual const char *GetReplaySubDir() const { return m_pShared->GetReplaySubDir(); } \
  52. virtual IReplayErrorSystem *GetErrorSystem() { return m_pShared->m_pErrorSystem; } \
  53. virtual IRecordingSessionManager *GetRecordingSessionManager() \
  54. { \
  55. return m_pShared->m_pRecordingSessionManager; \
  56. } \
  57. virtual CBaseRecordingSession *GetRecordingSession( ReplayHandle_t hSession ) \
  58. { \
  59. return static_cast< CBaseRecordingSession * >( m_pShared->m_pRecordingSessionManager->Find( hSession ) ); \
  60. } \
  61. virtual CBaseRecordingSessionBlockManager *GetRecordingSessionBlockManager() \
  62. { \
  63. return m_pShared->m_pRecordingSessionBlockManager; \
  64. }
  65. //----------------------------------------------------------------------------------------
  66. class CJob;
  67. bool RunJobToCompletion( IThreadPool *pThreadPool, CJob *pJob );
  68. //----------------------------------------------------------------------------------------
  69. #endif // SHARED_REPLAYCONTEXT_H