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.

57 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VSTDLIB_IKEYVALUESSYSTEM_H
  8. #define VSTDLIB_IKEYVALUESSYSTEM_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vstdlib/vstdlib.h"
  13. // handle to a KeyValues key name symbol
  14. typedef int HKeySymbol;
  15. #define INVALID_KEY_SYMBOL (-1)
  16. class IBaseFileSystem;
  17. class KeyValues;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Interface to shared data repository for KeyValues (included in vgui_controls.lib)
  20. // allows for central data storage point of KeyValues symbol table
  21. //-----------------------------------------------------------------------------
  22. class IKeyValuesSystem
  23. {
  24. public:
  25. // registers the size of the KeyValues in the specified instance
  26. // so it can build a properly sized memory pool for the KeyValues objects
  27. // the sizes will usually never differ but this is for versioning safety
  28. virtual void RegisterSizeofKeyValues(int size) = 0;
  29. // allocates/frees a KeyValues object from the shared mempool
  30. virtual void *AllocKeyValuesMemory(int size) = 0;
  31. virtual void FreeKeyValuesMemory(void *pMem) = 0;
  32. // symbol table access (used for key names)
  33. virtual HKeySymbol GetSymbolForString( const char *name, bool bCreate = true ) = 0;
  34. virtual const char *GetStringForSymbol(HKeySymbol symbol) = 0;
  35. // for debugging, adds KeyValues record into global list so we can track memory leaks
  36. virtual void AddKeyValuesToMemoryLeakList(void *pMem, HKeySymbol name) = 0;
  37. virtual void RemoveKeyValuesFromMemoryLeakList(void *pMem) = 0;
  38. // maintain a cache of KeyValues we load from disk. This saves us quite a lot of time on app startup.
  39. virtual void AddFileKeyValuesToCache( const KeyValues* _kv, const char *resourceName, const char *pathID ) = 0;
  40. virtual bool LoadFileKeyValuesFromCache( KeyValues* _outKv, const char *resourceName, const char *pathID, IBaseFileSystem *filesystem ) const = 0;
  41. virtual void InvalidateCache( ) = 0;
  42. virtual void InvalidateCacheForFile( const char *resourceName, const char *pathID ) = 0;
  43. };
  44. VSTDLIB_INTERFACE IKeyValuesSystem *KeyValuesSystem();
  45. // #define KEYVALUESSYSTEM_INTERFACE_VERSION "KeyValuesSystem002"
  46. #endif // VSTDLIB_IKEYVALUESSYSTEM_H