ppDependableFile.h 2.2 KB

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