ppDependableFile.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Filename: ppDependableFile.h
  2. // Created by: drose (15Oct00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef PPDEPENDABLEFILE_H
  6. #define PPDEPENDABLEFILE_H
  7. #include "ppremake.h"
  8. #include <set>
  9. #include <vector>
  10. #include <time.h>
  11. #ifdef HAVE_SYS_TIME_H
  12. #include <sys/time.h>
  13. #endif
  14. class PPDirectory;
  15. ///////////////////////////////////////////////////////////////////
  16. // Class : PPDependableFile
  17. // Description : Corresponds to a single C/C++ source file, either a
  18. // .c file or a .h file, that can be scanned for a
  19. // number of #include statements. This file may both
  20. // depend on other files, as well as being depended upon
  21. // in turn. This is used to resolved inter-file
  22. // dependencies.
  23. ////////////////////////////////////////////////////////////////////
  24. class PPDependableFile {
  25. public:
  26. PPDependableFile(PPDirectory *directory, const string &filename);
  27. bool update_from_cache(const vector<string> &words);
  28. void clear_cache();
  29. void write_cache(ostream &out);
  30. PPDirectory *get_directory() const;
  31. const string &get_filename() const;
  32. string get_pathname() const;
  33. string get_fullpath() const;
  34. string get_dirpath() const;
  35. bool exists();
  36. time_t get_mtime();
  37. int get_num_dependencies();
  38. PPDependableFile *get_dependency(int n);
  39. void get_complete_dependencies(vector<PPDependableFile *> &files);
  40. void get_complete_dependencies(set<PPDependableFile *> &files);
  41. bool is_circularity();
  42. string get_circularity();
  43. bool was_examined() const;
  44. bool was_cached() const;
  45. private:
  46. void update_dependencies();
  47. PPDependableFile *compute_dependencies(string &circularity);
  48. void stat_file();
  49. PPDirectory *_directory;
  50. string _filename;
  51. enum Flags {
  52. F_updating = 0x001,
  53. F_updated = 0x002,
  54. F_circularity = 0x004,
  55. F_statted = 0x008,
  56. F_exists = 0x010,
  57. F_from_cache = 0x020,
  58. F_bad_cache = 0x040,
  59. };
  60. int _flags;
  61. string _circularity;
  62. time_t _mtime;
  63. class Dependency {
  64. public:
  65. PPDependableFile *_file;
  66. bool _okcircular;
  67. bool operator < (const Dependency &other) const;
  68. };
  69. typedef vector<Dependency> Dependencies;
  70. Dependencies _dependencies;
  71. typedef vector<string> ExtraIncludes;
  72. ExtraIncludes _extra_includes;
  73. };
  74. #endif