-class TraceAnalyzer {
- /* Map for tracking resource dependencies between calls. */
- std::map<const char *, std::set<unsigned>, stringCompare > resources;
-
- /* The final set of calls required. This consists of calls added
- * explicitly with the require() method as well as all calls
- * implicitly required by those through resource dependencies. */
- std::set<unsigned> required;
-
-public:
- TraceAnalyzer() {}
- ~TraceAnalyzer() {}
-
- /* Compute and record all the resources provided by this call. */
- void analyze(trace::Call *call) {
- resources["state"].insert(call->no);
- }
-
- /* Require this call and all of its dependencies to be included in
- * the final trace. */
- void require(trace::Call *call) {
- std::set<unsigned> *dependencies;
- std::set<unsigned>::iterator i;
-
- /* First, find and insert all calls that this call depends on. */
- dependencies = &resources["state"];
- for (i = dependencies->begin(); i != dependencies->end(); i++) {
- required.insert(*i);
- }
- resources["state"].clear();
-
- /* Then insert this call itself. */
- required.insert(call->no);
- }
-
- /* Return a set of all the required calls, (both those calls added
- * explicitly with require() and those implicitly depended
- * upon. */
- std::set<unsigned> *get_required(void) {
- return &required;
- }
-};
-