ppDependableFile.h 2.2 KB

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