cmCacheManager.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL };
  25. class CacheEntry
  26. {
  27. public:
  28. std::string m_Value;
  29. CacheEntryType m_Type;
  30. };
  31. public:
  32. typedef std::map<std::string, CacheEntry> CacheEntryMap;
  33. /**
  34. * Types for the cache entries. These are useful as
  35. * hints for a cache editor program. Path should bring
  36. * up a file chooser, BOOL a check box, and STRING a
  37. * text entry box, FILEPATH is a full path to a file which
  38. * can be different than just a path input
  39. */
  40. static CacheEntryType StringToType(const char*);
  41. //! Singleton pattern get instance of the cmCacheManager.
  42. static cmCacheManager* GetInstance();
  43. //! Load a cache for given makefile. Loads from ouput home.
  44. bool LoadCache(cmMakefile*);
  45. //! Save cache for given makefile. Saves to ouput home CMakeCache.txt
  46. bool SaveCache(cmMakefile*) const;
  47. //! Add an entry into the cache
  48. void AddCacheEntry(const char* key, const char* value, CacheEntryType type);
  49. //! Add a BOOL entry into the cache
  50. void AddCacheEntry(const char* key, bool);
  51. //! Remove an entry from the cache
  52. void RemoveCacheEntry(const char* key);
  53. //! Print the cache to a stream
  54. CacheEntry *GetCacheEntry(const char *key);
  55. //! Get a value from the cache given a key
  56. const char* GetCacheValue(const char* key) const;
  57. //! Test a boolean cache entry to see if it is true or false, returns false
  58. // if no entry.
  59. bool IsOn(const char*) const;
  60. //! Print the cache to a stream
  61. void PrintCache(std::ostream&) const;
  62. //! Get the cache map ivar.
  63. const CacheEntryMap &GetCacheMap() const { return m_Cache; }
  64. private:
  65. static cmCacheManager* s_Instance;
  66. CacheEntryMap m_Cache;
  67. };
  68. #endif