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.

114 lines
3.3 KiB

  1. //========= Copyright 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 TIER3_H
  7. #define TIER3_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. #include "tier2/tier2.h"
  12. //-----------------------------------------------------------------------------
  13. // Forward declarations
  14. //-----------------------------------------------------------------------------
  15. class IStudioRender;
  16. class IMatSystemSurface;
  17. class IDataCache;
  18. class IMDLCache;
  19. class IVideoServices;
  20. class IDmeMakefileUtils;
  21. class IPhysicsCollision;
  22. class ISoundEmitterSystemBase;
  23. class IVTex;
  24. namespace vgui
  25. {
  26. class ISurface;
  27. class IVGui;
  28. class IInput;
  29. class IPanel;
  30. class ILocalize;
  31. class ISchemeManager;
  32. class ISystem;
  33. }
  34. //-----------------------------------------------------------------------------
  35. // These tier3 libraries must be set by any users of this library.
  36. // They can be set by calling ConnectTier3Libraries.
  37. // It is hoped that setting this, and using this library will be the common mechanism for
  38. // allowing link libraries to access tier3 library interfaces
  39. //-----------------------------------------------------------------------------
  40. extern IStudioRender *g_pStudioRender;
  41. extern IStudioRender *studiorender;
  42. extern IMatSystemSurface *g_pMatSystemSurface;
  43. extern vgui::ISurface *g_pVGuiSurface;
  44. extern vgui::IInput *g_pVGuiInput;
  45. extern vgui::IVGui *g_pVGui;
  46. extern vgui::IPanel *g_pVGuiPanel;
  47. extern vgui::ILocalize *g_pVGuiLocalize;
  48. extern vgui::ISchemeManager *g_pVGuiSchemeManager;
  49. extern vgui::ISystem *g_pVGuiSystem;
  50. extern IDataCache *g_pDataCache; // FIXME: Should IDataCache be in tier2?
  51. extern IMDLCache *g_pMDLCache;
  52. extern IMDLCache *mdlcache;
  53. extern IVideoServices *g_pVideo;
  54. extern IDmeMakefileUtils *g_pDmeMakefileUtils;
  55. extern IPhysicsCollision *g_pPhysicsCollision;
  56. extern ISoundEmitterSystemBase *g_pSoundEmitterSystem;
  57. extern IVTex *g_pVTex;
  58. //-----------------------------------------------------------------------------
  59. // Call this to connect to/disconnect from all tier 3 libraries.
  60. // It's up to the caller to check the globals it cares about to see if ones are missing
  61. //-----------------------------------------------------------------------------
  62. void ConnectTier3Libraries( CreateInterfaceFn *pFactoryList, int nFactoryCount );
  63. void DisconnectTier3Libraries();
  64. //-----------------------------------------------------------------------------
  65. // Helper empty implementation of an IAppSystem for tier2 libraries
  66. //-----------------------------------------------------------------------------
  67. template< class IInterface, int ConVarFlag = 0 >
  68. class CTier3AppSystem : public CTier2AppSystem< IInterface, ConVarFlag >
  69. {
  70. typedef CTier2AppSystem< IInterface, ConVarFlag > BaseClass;
  71. public:
  72. CTier3AppSystem( bool bIsPrimaryAppSystem = true ) : BaseClass( bIsPrimaryAppSystem )
  73. {
  74. }
  75. virtual bool Connect( CreateInterfaceFn factory )
  76. {
  77. if ( !BaseClass::Connect( factory ) )
  78. return false;
  79. if ( BaseClass::IsPrimaryAppSystem() )
  80. {
  81. ConnectTier3Libraries( &factory, 1 );
  82. }
  83. return true;
  84. }
  85. virtual void Disconnect()
  86. {
  87. if ( BaseClass::IsPrimaryAppSystem() )
  88. {
  89. DisconnectTier3Libraries();
  90. }
  91. BaseClass::Disconnect();
  92. }
  93. };
  94. #endif // TIER3_H