cmCacheManager.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #ifndef cmCacheManager_h
  12. #define cmCacheManager_h
  13. #include "cmStandardIncludes.h"
  14. /** \class cmCacheManager
  15. * \brief Control class for cmake's cache
  16. *
  17. * Load and Save CMake cache files.
  18. *
  19. */
  20. class cmCacheManager
  21. {
  22. public:
  23. /**
  24. * Types for the cache entries. These are useful as
  25. * hints for a cache editor program. Path should bring
  26. * up a file chooser, BOOL a check box, and STRING a
  27. * text entry box.
  28. */
  29. enum CacheEntryType{ BOOL=0, PATH, STRING };
  30. static CacheEntryType StringToType(const char*);
  31. //! Singleton pattern get instance of the cmCacheManager.
  32. static cmCacheManager* GetInstance();
  33. //! Load a cache from file
  34. bool LoadCache(const char* path);
  35. //! Save the cache to a file
  36. bool SaveCache(const char* path);
  37. //! Add an entry into the cache
  38. void AddCacheEntry(const char* key, const char* value, CacheEntryType type);
  39. //! Get a value from the cache given a key
  40. const char* GetCacheValue(const char* key);
  41. private:
  42. static cmCacheManager* s_Instance;
  43. class CacheEntry
  44. {
  45. public:
  46. std::string m_Value;
  47. CacheEntryType m_Type;
  48. };
  49. std::map<std::string, CacheEntry> m_Cache;
  50. };
  51. #endif