Counter Strike : Global Offensive Source Code
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.

91 lines
3.0 KiB

  1. //======= Copyright (c) 1996-2009, Valve Corporation, All rights reserved. ======
  2. //
  3. //===============================================================================
  4. #ifndef DEMOBUFFER_H
  5. #define DEMOBUFFER_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //-----------------------------------------------------------------------------
  10. // Includes
  11. //-----------------------------------------------------------------------------
  12. #include "utlbuffer.h"
  13. #include "utllinkedlist.h"
  14. #include <tier2/utlstreambuffer.h>
  15. #include "interface.h"
  16. #include "demofile/demoformat.h"
  17. //-----------------------------------------------------------------------------
  18. struct DemoBufferInitParams_t
  19. {
  20. virtual ~DemoBufferInitParams_t() {} // Need this to make polymorphic
  21. };
  22. struct StreamDemoBufferInitParams_t : public DemoBufferInitParams_t
  23. {
  24. StreamDemoBufferInitParams_t( char const* filename, char const* path, int flags, int openfileflags ) : pFilename( filename ), pszPath( path ), nFlags( flags ), nOpenFileFlags( openfileflags ) {}
  25. char const* pFilename;
  26. char const* pszPath;
  27. int nFlags;
  28. int nOpenFileFlags;
  29. };
  30. struct MemoryDemoBufferInitParams_t : public DemoBufferInitParams_t
  31. {
  32. MemoryDemoBufferInitParams_t( int maxsize ) : nMaxSize( maxsize ) {}
  33. int nMaxSize; // TODO: make use of this parameter
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Demo buffer interface - allows for one implementation of the demo format
  37. // (demofile.cpp) with a common interface for writing to disk or writing to
  38. // a buffer in memory.
  39. //-----------------------------------------------------------------------------
  40. class IDemoBuffer : public IBaseInterface
  41. {
  42. public:
  43. virtual bool Init( DemoBufferInitParams_t const& params ) = 0;
  44. virtual void NotifySignonComplete() = 0;
  45. virtual bool IsInitialized() const = 0;
  46. virtual bool IsValid() const = 0;
  47. virtual void WriteHeader( const void *pData, int nSize ) = 0;
  48. virtual void NotifyBeginFrame() = 0;
  49. virtual void NotifyEndFrame() = 0;
  50. // Change where I'm writing (put)/reading (get)
  51. virtual void SeekPut( bool bAbsolute, int offset ) = 0;
  52. virtual void SeekGet( bool bAbsolute, int offset ) = 0;
  53. // Where am I writing (put)/reading (get)?
  54. virtual int TellPut( ) const = 0;
  55. virtual int TellGet( ) const = 0;
  56. // What's the most I've ever written?
  57. virtual int TellMaxPut( ) const = 0;
  58. virtual char GetChar( ) = 0;
  59. virtual unsigned char GetUnsignedChar( ) = 0;
  60. virtual int GetInt( ) = 0;
  61. virtual void Get( void* pMem, int size ) = 0;
  62. virtual void PutChar( char c ) = 0;
  63. virtual void PutUnsignedChar( unsigned char uc ) = 0;
  64. virtual void PutInt( int i ) = 0;
  65. virtual void Put( const void* pMem, int size ) = 0;
  66. virtual void WriteTick( int nTick ) = 0;
  67. virtual void UpdateStartTick( int& nStartTick ) const = 0;
  68. virtual void DumpToFile( char const* pFilename, const demoheader_t &header ) const = 0;
  69. };
  70. IDemoBuffer *CreateDemoBuffer( bool bMemoryBuffer, const DemoBufferInitParams_t &params );
  71. #endif // DEMOBUFFER_H