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.

103 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef BASERECORDINGSESSIONMANAGER_H
  5. #define BASERECORDINGSESSIONMANAGER_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "tier0/platform.h"
  11. #include "utlstring.h"
  12. #include "utllinkedlist.h"
  13. #include "replay/replayhandle.h"
  14. #include "replay/irecordingsessionmanager.h"
  15. #include "genericpersistentmanager.h"
  16. //----------------------------------------------------------------------------------------
  17. class CBaseRecordingSession;
  18. class CBaseRecordingSessionBlock;
  19. class KeyValues;
  20. class IReplayContext;
  21. //----------------------------------------------------------------------------------------
  22. //
  23. // Manages and serializes all replay recording session data - instanced on both the client
  24. // and server via CClientRecordingSessionManager and CServerRecordingSessionManager.
  25. //
  26. class CBaseRecordingSessionManager : public CGenericPersistentManager< CBaseRecordingSession >,
  27. public IRecordingSessionManager
  28. {
  29. typedef CGenericPersistentManager< CBaseRecordingSession > BaseClass;
  30. public:
  31. CBaseRecordingSessionManager( IReplayContext *pContext );
  32. virtual ~CBaseRecordingSessionManager();
  33. virtual bool Init();
  34. virtual CBaseRecordingSession *OnSessionStart( int nCurrentRecordingStartTick, const char *pSessionName );
  35. virtual void OnSessionEnd();
  36. void DeleteSession( ReplayHandle_t hSession, bool bForce );
  37. const char *GetCurrentSessionName() const;
  38. int GetCurrentSessionBlockIndex() const;
  39. CBaseRecordingSession *FindSessionByName( const char *pSessionName );
  40. // This is here so that server-side cleanup can be done for a ditched session. See calling code for details.
  41. void DoSessionCleanup();
  42. //
  43. // IRecordingSessionManager
  44. //
  45. virtual CBaseRecordingSession *FindSession( ReplayHandle_t hSession );
  46. virtual const CBaseRecordingSession *FindSession( ReplayHandle_t hSession ) const;
  47. virtual void FlagSessionForFlush( CBaseRecordingSession *pSession, bool bForceImmediate );
  48. virtual int GetServerStartTickForSession( ReplayHandle_t hSession );
  49. // Get the recording session in progress
  50. CBaseRecordingSession *GetRecordingSessionInProgress() { return m_pRecordingSession; }
  51. bool LastSessionDitched() const { return m_bLastSessionDitched; }
  52. protected:
  53. //
  54. // CGenericPersistentManager
  55. //
  56. virtual const char *GetIndexFilename() const { return "sessions." GENERIC_FILE_EXTENSION; }
  57. virtual const char *GetRelativeIndexPath() const;
  58. virtual const char *GetDebugName() const { return "session manager"; }
  59. virtual void Think();
  60. //
  61. // CBaseThinker
  62. //
  63. virtual float GetNextThinkTime() const;
  64. IReplayContext *m_pContext;
  65. CBaseRecordingSession *m_pRecordingSession; // Currently recording session, or NULL if not recording
  66. bool m_bLastSessionDitched;
  67. virtual bool CanDeleteSession( ReplayHandle_t hSession ) const { return true; }
  68. virtual bool ShouldUnloadSessions() const { return false; }
  69. virtual void OnAllSessionsDeleted() {}
  70. private:
  71. void DeleteSessionThink();
  72. void MarkSessionForDelete( ReplayHandle_t hSession );
  73. CUtlLinkedList< ReplayHandle_t, int > m_lstSessionsToDelete;
  74. };
  75. //----------------------------------------------------------------------------------------
  76. #endif // BASERECORDINGSESSIONMANAGER_H