1 #include <QObject> 2 #include "../core.hh" 3 4 namespace cpprofiler 5 { 6 namespace tree 7 { 8 9 class NodeStats : public QObject 10 { 11 Q_OBJECT 12 int branch_ = 0; 13 int undet_ = 0; 14 int failed_ = 0; 15 int skipped_ = 0; 16 int solved_ = 0; 17 int max_depth_ = 0; 18 19 public: branchCount() const20 int branchCount() const { return branch_; } 21 undeterminedCount() const22 int undeterminedCount() const { return undet_; } 23 failedCount() const24 int failedCount() const { return failed_; } 25 skippedCount() const26 int skippedCount() const { return skipped_; } 27 solvedCount() const28 int solvedCount() const { return solved_; } 29 maxDepth() const30 int maxDepth() const { return max_depth_; } 31 add_branch(int n)32 void add_branch(int n) 33 { 34 branch_ = branch_ + n; 35 } 36 subtract_undetermined(int n)37 void subtract_undetermined(int n) 38 { 39 undet_ = undet_ - n; 40 } 41 add_undetermined(int n)42 void add_undetermined(int n) 43 { 44 undet_ = undet_ + n; 45 } 46 add_failed(int n)47 void add_failed(int n) 48 { 49 failed_ = failed_ + n; 50 } 51 add_solved(int n)52 void add_solved(int n) 53 { 54 solved_ = solved_ + n; 55 } 56 add_skipped(int n)57 void add_skipped(int n) 58 { 59 skipped_ += n; 60 } 61 addNode(NodeStatus status)62 void addNode(NodeStatus status) 63 { 64 65 switch (status) 66 { 67 case NodeStatus::BRANCH: 68 { 69 add_branch(1); 70 } 71 break; 72 case NodeStatus::FAILED: 73 { 74 add_failed(1); 75 } 76 break; 77 case NodeStatus::SOLVED: 78 { 79 add_solved(1); 80 } 81 break; 82 case NodeStatus::SKIPPED: 83 { 84 add_skipped(1); 85 } 86 break; 87 case NodeStatus::UNDETERMINED: 88 { 89 undet_ += 1; 90 } 91 break; 92 } 93 } 94 95 /// see if max depth needs to be updated to d inform_depth(int d)96 void inform_depth(int d) 97 { 98 if (d > max_depth_) 99 { 100 max_depth_ = d; 101 } 102 } 103 104 signals: 105 106 void stats_changed(); 107 }; 108 109 } // namespace tree 110 } // namespace cpprofiler