]> git.tdb.fi Git - builder.git/blobdiff - source/analyzer.h
Use default member initializers and constructor delegation
[builder.git] / source / analyzer.h
index c5c6ba2891de6cf8ba144763b488d69f05e1d889..5827480cdd913765a7353e73a97068d20b6f4f27 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef ANALYZER_H_
 #define ANALYZER_H_
 
-#include <list>
+#include <map>
+#include <set>
 #include <string>
 #include <vector>
 
@@ -16,31 +17,42 @@ class Analyzer
 public:
        enum Mode
        {
-               DEPS,     /// Skip over "trivial" targets such as Install and Compile
-               ALLDEPS,  /// Print out absolutely every target
-               REBUILD,  /// Print targets that are going to be rebuilt
-               RDEPS     /// Print targets that depend on the given targets (NYI)
+               DEPS,     //< Skip over "trivial" targets such as InstalledFile
+               ALLDEPS,  //< Print out absolutely every target
+               REBUILD,  //< Print targets that are going to be rebuilt
+               RDEPS     //< Print targets that depend on the given targets
        };
 
-       Analyzer(Builder &);
-       void set_mode(Mode m)          { mode=m; }
-       void set_max_depth(unsigned m) { max_depth=m; }
-       void set_full_paths(bool f)    { full_paths=f; }
-       void analyze();
 private:
-       typedef std::vector<std::string> TableRow;
-       typedef std::list<TableRow> Table;
+       using TableRow = std::vector<std::string>;
+
+       Builder &builder;
+       Mode mode = DEPS;
+       std::vector<TableRow> table;
+       unsigned max_depth = 0;
+       bool full_paths = false;
+       std::map<const Target *, std::set<Target *> > rdepends;
+
+public:
+       Analyzer(Builder &);
+
+       void set_mode(Mode m) { mode = m; }
+       void set_max_depth(unsigned m) { max_depth = m; }
+       void set_full_paths(bool f) { full_paths = f; }
 
-       Builder  &builder;
-       Mode     mode;
-       Table    table;
-       unsigned max_depth;
-       bool     full_paths;
+       /// Performs the analysis and prints out the resulting dependency tree.
+       void analyze();
 
+private:
+       /** Adds rows for a target, then recursively adds rows for dependencies as
+       needed. */
        void build_depend_table(Target &, unsigned);
+
+       /// Prints out the table that resulted from the analysis.
        void print_table() const;
 
-       static bool target_order(Target *, Target *);
+       static bool target_order(const Target *, const Target *);
+       static bool target_order_full(const Target *, const Target *);
 };
 
 #endif