00001 // idep_compiledep.h 00002 #ifndef INCLUDED_IDEP_COMPILEDEP 00003 #define INCLUDED_IDEP_COMPILEDEP 00004 00005 // This wrapper component defines 3 fully insulated classes: 00006 // idep_CompileDep: environment for analyzing compile-time dependencies 00007 // idep_RootFileIter: iterate over the specified root file names 00008 // idep_HeaderFileIter: iterate over the dependencies of each root file 00009 00010 #include <iosfwd> 00011 class idep_RootFileIter; 00012 class idep_HeaderFileIter; 00013 00014 class idep_CompileDep_i; 00015 class idep_CompileDep { 00016 idep_CompileDep_i *d_this; 00017 00018 friend class idep_RootFileIter; 00019 friend class idep_HeaderFileIter; 00020 00021 private: 00022 idep_CompileDep(const idep_CompileDep&); // not implemented 00023 idep_CompileDep& operator=(const idep_CompileDep&); // not implemented 00024 00025 public: 00026 // CREATORS 00027 idep_CompileDep(); 00028 ~idep_CompileDep(); 00029 00030 // MANIPULATORS 00031 void addIncludeDirectory(const char *dirName); 00032 // Add a directory to be searched for include files. 00033 // Errors will be detected during the calculation process. 00034 00035 int readIncludeDirectories(const char *file); 00036 // Add a list of include directories read from a specified file. 00037 // This function assumes that each contiguous sequence of 00038 // non-whitespace characters represents directory to be added. 00039 // This function returns 0 unless the specified file is unreadable 00040 // or contains non-ascii characters. 00041 00042 void addRootFile(const char *fileName); 00043 // Add the name of a file to be analyzed. Errors in reading this file 00044 // will be detected only when the calculate() operation is invoked. 00045 00046 int readRootFiles(const char *file); 00047 // Add a list of root file names read from a specified file. This 00048 // function assumes that each contiguous sequence of non-whitespace 00049 // characters represents a file name to be added. The effect is the 00050 // same as if each root file name had been added individually. This 00051 // function returns 0 unless the specified file is unreadable or 00052 // contains non-ascii characters. Errors in reading individual root 00053 // files named there in will be detected only when a processing 00054 // operation is invoked. 00055 00056 void inputRootFiles(); 00057 // Similar to readRootFiles except that input is presumed to come 00058 // from <stdin>, which is reset on eof. No check is done for 00059 // non-ascii characters. 00060 00061 int calculate(std::ostream& err, int recursionFlag = 1); 00062 // Calculate compile-time dependencies among the specified set of 00063 // rootfiles. Return 0 on success, non-zero on error. Errors will 00064 // be printed to the indicated output stream (err). By default, 00065 // calculation of dependencies will recurse even for files (such as 00066 // (compiler supplied headers) defined outside the current directory. 00067 // Specifying 0 as the value of the optional second argument suppresses 00068 // recursive investigation of dependencies within external files. 00069 // Note that turning off recursion is potentially much faster, but 00070 // provides an incomplete list of compile-time dependencies. 00071 }; 00072 00073 std::ostream &operator<<(std::ostream& o, const idep_CompileDep&); 00074 // output dependencies in standard format: 00075 // A series of files is emitted one per line, with a blank line 00076 // denoting the end of each series. The first file in each series is 00077 // is the root file. Each subsequent file in the series represents a 00078 // header file upon which the root file depends at compile time. 00079 00080 class idep_RootFileIter_i; 00081 class idep_RootFileIter { 00082 idep_RootFileIter_i *d_this; 00083 00084 friend class idep_HeaderFileIter; 00085 00086 private: 00087 idep_RootFileIter(const idep_RootFileIter&); // not implemented 00088 idep_RootFileIter& operator=(const idep_RootFileIter&); // not implemented 00089 00090 public: 00091 // CREATORS 00092 idep_RootFileIter(const idep_CompileDep& compileDep); 00093 ~idep_RootFileIter(); 00094 00095 // MANIPULATORS 00096 void operator++(); 00097 00098 // ACCESSORS 00099 operator const void *() const; 00100 const char *operator()() const; 00101 // Returns the name of the current root file. 00102 }; 00103 00104 class idep_HeaderFileIter_i; 00105 class idep_HeaderFileIter { 00106 idep_HeaderFileIter_i *d_this; 00107 00108 private: 00109 idep_HeaderFileIter(const idep_HeaderFileIter&); // not impl. 00110 idep_HeaderFileIter& operator=(const idep_HeaderFileIter&); // not impl. 00111 00112 public: 00113 // CREATORS 00114 idep_HeaderFileIter(const idep_RootFileIter& rootFileIter); 00115 ~idep_HeaderFileIter(); 00116 00117 // MANIPULATORS 00118 void operator++(); 00119 00120 // ACCESSORS 00121 operator const void *() const; 00122 const char *operator()() const; 00123 // Returns the name of the current file on which the current root 00124 // file depends (either directly or indirectly) at compile time. 00125 }; 00126 00127 #endif 00128 00129
1.3.9.1