ppDependableFile.h 2.2 KB

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