Manak  2.0.0
t_manak_case.hpp
Go to the documentation of this file.
1 #ifndef MANAK_T_MANAK_CASE_HPP_INCLUDED
2 #define MANAK_T_MANAK_CASE_HPP_INCLUDED
3 
4 namespace manak
5 {
6 
7 template<class Case, typename RType, typename... Args>
8 class TManakCase : public Case
9 {
10  public:
12  : Case("", "", 0, 0, ""){}
13 
14  TManakCase(const std::string& name,
15  const std::string& library_name,
16  std::function<RType(Args...)> t_function,
17  double tolerance,
18  const size_t iterations,
19  double success_p)
20  : Case(name, library_name, tolerance, iterations, success_p),
22  {
23 
24  }
25 
26  TManakCase* AddArgs(Args... args)
27  {
28  std::tuple<Args...> temp(args...);
29  this->run_functions.emplace_back("", [=](){utils::Caller(t_function, temp); });
30  return this;
31  }
32 
33  TManakCase* AddArgs_N(const std::string& name, Args... args)
34  {
35  std::tuple<Args...> temp(args...);
36  this->run_functions.emplace_back(name, [=](){utils::Caller(t_function, temp); });
37  return this;
38  }
39 
40  template<typename T, typename... Args2>
41  TManakCase* AddCustomArgs(T fun, Args2... params)
42  {
43  std::list<std::tuple<Args...>> args = fun(params...);
44  for(auto s_arg : args)
45  {
47  }
48  return this;
49  }
50 
51  template<typename... Args2>
52  TManakCase* AddCustomArgs(std::list<std::tuple<Args...>> (&fun)(Args2...), Args2... params)
53  {
54  std::list<std::tuple<Args...>> args = fun(params...);
55  for(auto s_arg : args)
56  {
58  }
59  return this;
60  }
61 
62  template<typename ST, typename... Args2>
63  TManakCase* AddCustomArgs_N(std::list<std::tuple<ST, Args...>> (&fun)(Args2...), Args2... params)
64  {
65  std::list<std::tuple<ST, Args...>> args = fun(params...);
66  for(auto s_arg : args)
67  {
69  }
70  return this;
71  }
72 
73 private:
74  std::function<RType(Args...)> t_function;
75  size_t iter;
76 };
77 
78 class BenchmarkCase;
79 
80 template<class Case, typename RType, typename... Args>
81 TManakCase<Case, RType, Args...>* CTManakCase(const std::string& name,
82  const std::string& library_name,
83  RType (*fun)(Args...),
84  double tolerance,
85  const size_t iterations,
86  double success_p)
87 {
88  return new TManakCase<Case, RType, Args...>(name, library_name, std::function<RType(Args...)>(fun), tolerance, iterations, success_p);
89 }
90 
91 template<class Case, typename RType, typename... Args>
92 TManakCase<Case, RType, Args...>* CTManakCase(const std::string& name,
93  const std::string& library_name,
94  std::function<RType(Args...)> fun,
95  double tolerance,
96  const size_t iterations,
97  double success_p)
98 {
99  return new TManakCase<Case, RType, Args...>(name, library_name, fun, tolerance, iterations, success_p);
100 }
101 
102 }
103 
104 #endif // MANAK_T_MANAK_CASE_HPP_INCLUDED
TManakCase * AddCustomArgs_N(std::list< std::tuple< ST, Args...>>(&fun)(Args2...), Args2...params)
TManakCase * AddArgs_N(const std::string &name, Args...args)
RType Caller(std::function< RType(Args...)> fun, P params)
TManakCase< Case, RType, Args...> * CTManakCase(const std::string &name, const std::string &library_name, RType(*fun)(Args...), double tolerance, const size_t iterations, double success_p)
TManakCase * AddArgs(Args...args)
TManakCase * AddCustomArgs(std::list< std::tuple< Args...>>(&fun)(Args2...), Args2...params)
TManakCase * AddCustomArgs(T fun, Args2...params)
std::function< RType(Args...)> BindToObject(RType(C::*fun)(Args...), C *c)
TManakCase(const std::string &name, const std::string &library_name, std::function< RType(Args...)> t_function, double tolerance, const size_t iterations, double success_p)
std::function< RType(Args...)> t_function