cmListFileCache.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmListFileCache_h
  14. #define cmListFileCache_h
  15. #include "cmStandardIncludes.h"
  16. /** \class cmListFileCache
  17. * \brief A class to cache list file contents.
  18. *
  19. * cmListFileCache is a class used to cache the contents of parsed
  20. * cmake list files.
  21. */
  22. struct cmListFileFunction
  23. {
  24. std::string m_Name;
  25. std::vector<std::string> m_Arguments;
  26. };
  27. struct cmListFile
  28. {
  29. cmListFile()
  30. :m_ModifiedTime(0)
  31. {
  32. }
  33. long int m_ModifiedTime;
  34. std::vector<cmListFileFunction> m_Functions;
  35. };
  36. class cmListFileCache
  37. {
  38. public:
  39. static cmListFileCache* GetInstance();
  40. static void ClearCache();
  41. /** Return the cached version of the given file.
  42. * If the file is not already in the cache, a cache entry
  43. * will be made. If there is an error loading the file,
  44. * NULL is returned.
  45. */
  46. cmListFile* GetFileCache(const char* path);
  47. private:
  48. // Cache the file
  49. bool CacheFile(const char* path);
  50. // private data
  51. typedef std::map<cmStdString, cmListFile> ListFileMap;
  52. ListFileMap m_ListFileCache; // file name to ListFile map
  53. static cmListFileCache* Instance; // singelton pointer
  54. };
  55. #endif