ppDependableFile.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. void update_from_cache(const vector<string> &words);
  28. void write_cache(ostream &out);
  29. PPDirectory *get_directory() const;
  30. const string &get_filename() const;
  31. string get_pathname() const;
  32. string get_dirpath() const;
  33. bool exists();
  34. time_t get_mtime();
  35. int get_num_dependencies();
  36. PPDependableFile *get_dependency(int n);
  37. void get_complete_dependencies(vector<PPDependableFile *> &files);
  38. void get_complete_dependencies(set<PPDependableFile *> &files);
  39. bool is_circularity();
  40. string get_circularity();
  41. bool was_examined() const;
  42. private:
  43. void update_dependencies();
  44. PPDependableFile *compute_dependencies(string &circularity);
  45. void stat_file();
  46. PPDirectory *_directory;
  47. string _filename;
  48. enum Flags {
  49. F_updating = 0x001,
  50. F_updated = 0x002,
  51. F_circularity = 0x004,
  52. F_statted = 0x008,
  53. F_exists = 0x010,
  54. F_from_cache = 0x020,
  55. };
  56. int _flags;
  57. string _circularity;
  58. time_t _mtime;
  59. class Dependency {
  60. public:
  61. PPDependableFile *_file;
  62. bool _okcircular;
  63. bool operator < (const Dependency &other) const;
  64. };
  65. typedef vector<Dependency> Dependencies;
  66. Dependencies _dependencies;
  67. typedef vector<string> ExtraIncludes;
  68. ExtraIncludes _extra_includes;
  69. };
  70. #endif