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.

82 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef SPEW_H
  5. #define SPEW_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. class ISpewer
  11. {
  12. public:
  13. virtual ~ISpewer() {}
  14. virtual void PrintBlockStart() const = 0;
  15. virtual void PrintBlockEnd() const = 0;
  16. virtual void PrintEmptyLine() const = 0;
  17. virtual void PrintEventStartMsg( const char *pMsg ) const = 0;
  18. virtual void PrintEventResult( bool bSuccess ) const = 0;
  19. virtual void PrintEventError( const char *pError ) const = 0;
  20. virtual void PrintTestHeader( const char *pHeader ) const = 0;
  21. virtual void PrintMsg( const char *pMsg ) const = 0;
  22. virtual void PrintValue( const char *pWhat, const char *pValue ) const = 0;
  23. };
  24. //----------------------------------------------------------------------------------------
  25. extern ISpewer *g_pDefaultSpewer;
  26. extern ISpewer *g_pBlockSpewer;
  27. extern ISpewer *g_pSimpleSpewer;
  28. extern ISpewer *g_pNullSpewer;
  29. //----------------------------------------------------------------------------------------
  30. class CSpewScope
  31. {
  32. public:
  33. CSpewScope( ISpewer *pSpewer )
  34. {
  35. m_pOldSpewer = g_pDefaultSpewer;
  36. g_pDefaultSpewer = pSpewer;
  37. }
  38. ~CSpewScope()
  39. {
  40. g_pDefaultSpewer = m_pOldSpewer;
  41. }
  42. private:
  43. ISpewer *m_pOldSpewer;
  44. };
  45. //----------------------------------------------------------------------------------------
  46. class CBaseSpewer : public ISpewer
  47. {
  48. public:
  49. CBaseSpewer( ISpewer *pSpewer = g_pDefaultSpewer );
  50. //
  51. // ISpewer implementation for shorthand.
  52. //
  53. virtual void PrintBlockStart() const { m_pSpewer->PrintBlockStart(); }
  54. virtual void PrintBlockEnd() const { m_pSpewer->PrintBlockEnd(); }
  55. virtual void PrintEmptyLine() const { m_pSpewer->PrintEmptyLine(); }
  56. virtual void PrintEventStartMsg( const char *pMsg ) const { m_pSpewer->PrintEventStartMsg( pMsg ); }
  57. virtual void PrintEventResult( bool bSuccess ) const { m_pSpewer->PrintEventResult( bSuccess ); }
  58. virtual void PrintEventError( const char *pError ) const { m_pSpewer->PrintEventError( pError ); }
  59. virtual void PrintTestHeader( const char *pHeader ) const { m_pSpewer->PrintTestHeader( pHeader ); }
  60. virtual void PrintMsg( const char *pMsg ) const { m_pSpewer->PrintMsg( pMsg ); }
  61. virtual void PrintValue( const char *pWhat, const char *pValue ) const { m_pSpewer->PrintValue( pWhat, pValue ); }
  62. private:
  63. ISpewer *m_pSpewer;
  64. };
  65. //----------------------------------------------------------------------------------------
  66. #endif // SPEW_H