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.

76 lines
1.8 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 TIER2DM_H
  7. #define TIER2DM_H
  8. #if defined( _WIN32 )
  9. #pragma once
  10. #endif
  11. #include "tier2/tier2.h"
  12. //-----------------------------------------------------------------------------
  13. // Set up methods related to datamodel interfaces
  14. //-----------------------------------------------------------------------------
  15. bool ConnectDataModel( CreateInterfaceFn factory );
  16. InitReturnVal_t InitDataModel();
  17. void ShutdownDataModel();
  18. void DisconnectDataModel();
  19. //-----------------------------------------------------------------------------
  20. // Helper empty implementation of an IAppSystem for tier2 libraries
  21. //-----------------------------------------------------------------------------
  22. template< class IInterface, int ConVarFlag = 0 >
  23. class CTier2DmAppSystem : public CTier2AppSystem< IInterface, ConVarFlag >
  24. {
  25. typedef CTier2AppSystem< IInterface, ConVarFlag > BaseClass;
  26. public:
  27. CTier2DmAppSystem( bool bIsPrimaryAppSystem = true ) : BaseClass( bIsPrimaryAppSystem )
  28. {
  29. }
  30. virtual bool Connect( CreateInterfaceFn factory )
  31. {
  32. if ( !BaseClass::Connect( factory ) )
  33. return false;
  34. ConnectDataModel( factory );
  35. return true;
  36. }
  37. virtual InitReturnVal_t Init()
  38. {
  39. InitReturnVal_t nRetVal = BaseClass::Init();
  40. if ( nRetVal != INIT_OK )
  41. return nRetVal;
  42. nRetVal = InitDataModel();
  43. if ( nRetVal != INIT_OK )
  44. return nRetVal;
  45. return INIT_OK;
  46. }
  47. virtual void Shutdown()
  48. {
  49. ShutdownDataModel();
  50. BaseClass::Shutdown();
  51. }
  52. virtual void Disconnect()
  53. {
  54. DisconnectDataModel();
  55. BaseClass::Disconnect();
  56. }
  57. };
  58. #endif // TIER2DM_H