cmCacheManager.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 cmMakefile;
  15. /** \class cmCacheManager
  16. * \brief Control class for cmake's cache
  17. *
  18. * Load and Save CMake cache files.
  19. *
  20. */
  21. class cmCacheManager
  22. {
  23. public:
  24. /**
  25. * Types for the cache entries. These are useful as
  26. * hints for a cache editor program. Path should bring
  27. * up a file chooser, BOOL a check box, and STRING a
  28. * text entry box, FILEPATH is a full path to a file which
  29. * can be different than just a path input
  30. */
  31. enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL };
  32. static CacheEntryType StringToType(const char*);
  33. //! Singleton pattern get instance of the cmCacheManager.
  34. static cmCacheManager* GetInstance();
  35. //! Load a cache for given makefile. Loads from ouput home.
  36. bool LoadCache(cmMakefile*);
  37. //! Save cache for given makefile. Saves to ouput home CMakeCache.txt
  38. bool SaveCache(cmMakefile*);
  39. //! Add an entry into the cache
  40. void AddCacheEntry(const char* key, const char* value, CacheEntryType type);
  41. //! Get a value from the cache given a key
  42. const char* GetCacheValue(const char* key);
  43. //! Print the cache to a stream
  44. void PrintCache(std::ostream&);
  45. private:
  46. static cmCacheManager* s_Instance;
  47. class CacheEntry
  48. {
  49. public:
  50. std::string m_Value;
  51. CacheEntryType m_Type;
  52. };
  53. std::map<std::string, CacheEntry> m_Cache;
  54. };
  55. #endif