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.

85 lines
2.0 KiB

  1. //===== Copyright � 2005-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: A higher level link library for general use in the game and tools.
  4. //
  5. //===========================================================================//
  6. #ifndef TIER1_H
  7. #define TIER1_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. #include "appframework/iappsystem.h"
  12. #include "tier1/convar.h"
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. //-----------------------------------------------------------------------------
  17. // Call this to connect to/disconnect from all tier 1 libraries.
  18. // It's up to the caller to check the globals it cares about to see if ones are missing
  19. //-----------------------------------------------------------------------------
  20. void ConnectTier1Libraries( CreateInterfaceFn *pFactoryList, int nFactoryCount );
  21. void DisconnectTier1Libraries();
  22. //-----------------------------------------------------------------------------
  23. // Helper empty implementation of an IAppSystem for tier2 libraries
  24. //-----------------------------------------------------------------------------
  25. template< class IInterface, int ConVarFlag = 0 >
  26. class CTier1AppSystem : public CTier0AppSystem< IInterface >
  27. {
  28. typedef CTier0AppSystem< IInterface > BaseClass;
  29. public:
  30. virtual bool Connect( CreateInterfaceFn factory )
  31. {
  32. if ( !BaseClass::Connect( factory ) )
  33. return false;
  34. ConnectTier1Libraries( &factory, 1 );
  35. return true;
  36. }
  37. virtual void Disconnect()
  38. {
  39. DisconnectTier1Libraries();
  40. BaseClass::Disconnect();
  41. }
  42. virtual InitReturnVal_t Init()
  43. {
  44. InitReturnVal_t nRetVal = BaseClass::Init();
  45. if ( nRetVal != INIT_OK )
  46. return nRetVal;
  47. if ( g_pCVar )
  48. {
  49. ConVar_Register( ConVarFlag );
  50. }
  51. return INIT_OK;
  52. }
  53. virtual void Shutdown()
  54. {
  55. if ( g_pCVar )
  56. {
  57. ConVar_Unregister( );
  58. }
  59. BaseClass::Shutdown( );
  60. }
  61. virtual AppSystemTier_t GetTier()
  62. {
  63. return APP_SYSTEM_TIER1;
  64. }
  65. };
  66. #endif // TIER1_H