Manak  2.0.0
result_collector.hpp
Go to the documentation of this file.
1 #ifndef MANAK_RESULT_COLLECTOR_HPP_INCLUDED
2 #define MANAK_RESULT_COLLECTOR_HPP_INCLUDED
3 
4 #include <iostream>
5 #include <string>
6 #include <map>
7 #include <list>
8 
10 
11 #include <manak/util/version.hpp>
13 
14 namespace manak
15 {
16 
17 struct RNode
18 {
20  : parent(parent), count(0)
21  {}
22 
23  virtual ~RNode() {}
24 
25  virtual RNode* AddSuite(ManakSuite* suite) = 0;
26 
27  virtual RNode* EraseSuite(ManakSuite* suite) = 0;
28 
29  virtual RNode* AddCase(ManakCase* bc) = 0;
30 
31  virtual void Run() = 0;
32 
33  virtual void Print() = 0;
34 
35  virtual void SaveForComparison(std::ostream& stream) = 0;
36 
37  virtual void LoadForComparison(const std::string& uname,
38  std::string library,
39  const std::list<double>& readings) = 0;
40 
41  virtual ManakSuite* GetSuite()
42  {
43  return NULL;
44  }
45 
47  size_t count;
48 };
49 
50 struct RCase : public RNode
51 {
53  : RNode(parent) {}
54 
55  ~RCase();
56 
58  {
59  (void)Suite;
60  return NULL;
61  }
62 
64 
66  {
67  (void)suite;
68  return NULL;
69  }
70 
71  MANAK_INLINE void Run();
72 
73  MANAK_INLINE void Print();
74 
75  MANAK_INLINE void SaveForComparison(std::ostream& stream);
76 
77  MANAK_INLINE void LoadForComparison(const std::string& uname,
78  std::string library,
79  const std::list<double>& readings);
80 
81  std::map<std::string, std::list<utils::ObjectStore>> results;
82  std::map<std::string, ManakCase*> children;
83 };
84 
85 struct RSuite : public RNode
86 {
88  :RNode(parent), suite(suite) {}
89 
91 
93 
95 
97 
98  MANAK_INLINE void Run();
99 
100  MANAK_INLINE void Print();
101 
103  {
104  return suite;
105  }
106 
107  MANAK_INLINE void SaveForComparison(std::ostream& stream);
108 
109  MANAK_INLINE void LoadForComparison(const std::string& uname,
110  std::string library,
111  const std::list<double>& readings);
112 
113  std::map<std::string, RNode*> next_suites;
114  std::map<std::string, RNode*> next_cases;
115 
117 };
118 
120 {
121  public:
123  : root(new RSuite(NULL, NULL)), current_node(root) {}
124 
126  {
127  delete root;
128  }
129 
131  {
132  static ResultCollector singleton;
133  return singleton;
134  }
135 
136  MANAK_INLINE void OpenSuite(ManakSuite* suite);
137 
138  MANAK_INLINE void AddCase(ManakCase* bc);
139 
140  MANAK_INLINE void CloseSuite();
141 
142  MANAK_INLINE void Run();
143 
144  MANAK_INLINE void SaveForComparison(std::ostream& stream);
145 
146  MANAK_INLINE void LoadForComparison(std::istream& stream);
147 
148  MANAK_INLINE void Print();
149 
150  private:
153 
154  bool isComp;
155  std::string compare_time;
156 };
157 
158 }
159 
160 #ifndef MANAK_USE_DYN_LINK
161 #include "result_collector.cpp"
162 #endif // MANAK_USE_DYN_LINK
163 
164 #endif // MANAK_RESULT_COLLECTOR_HPP_INCLUDED
MANAK_INLINE RNode * AddCase(ManakCase *bc)
MANAK_INLINE void Print()
virtual RNode * AddCase(ManakCase *bc)=0
MANAK_INLINE void Print()
RNode(RNode *parent)
MANAK_INLINE void Print()
std::map< std::string, RNode * > next_cases
ManakSuite * suite
ManakSuite * GetSuite()
virtual void Print()=0
std::map< std::string, ManakCase * > children
MANAK_INLINE void SaveForComparison(std::ostream &stream)
virtual void Run()=0
#define MANAK_INLINE
Check if user has opt for dynamic linking.
Definition: macro_utils.hpp:25
MANAK_INLINE ~RSuite()
MANAK_INLINE void Run()
RNode * AddSuite(ManakSuite *Suite)
MANAK_INLINE void LoadForComparison(std::istream &stream)
MANAK_INLINE void LoadForComparison(const std::string &uname, std::string library, const std::list< double > &readings)
virtual ManakSuite * GetSuite()
virtual void SaveForComparison(std::ostream &stream)=0
static ResultCollector & GlobalResultCollector()
MANAK_INLINE RNode * AddSuite(ManakSuite *Suite)
MANAK_INLINE void OpenSuite(ManakSuite *suite)
virtual RNode * EraseSuite(ManakSuite *suite)=0
virtual RNode * AddSuite(ManakSuite *suite)=0
MANAK_INLINE void LoadForComparison(const std::string &uname, std::string library, const std::list< double > &readings)
std::map< std::string, std::list< utils::ObjectStore > > results
MANAK_INLINE void AddCase(ManakCase *bc)
std::map< std::string, RNode * > next_suites
RCase(RNode *parent)
RSuite(RNode *parent, ManakSuite *suite)
MANAK_INLINE void CloseSuite()
MANAK_INLINE void Run()
virtual void LoadForComparison(const std::string &uname, std::string library, const std::list< double > &readings)=0
MANAK_INLINE void Run()
MANAK_INLINE void SaveForComparison(std::ostream &stream)
MANAK_INLINE void SaveForComparison(std::ostream &stream)
MANAK_INLINE RNode * AddCase(ManakCase *bc)
RNode * EraseSuite(ManakSuite *suite)
MANAK_INLINE RNode * EraseSuite(ManakSuite *suite)