TVM  0.9.4
SolvingRequirements.h
Go to the documentation of this file.
1 
3 #pragma once
4 
9 
10 #include <Eigen/Core>
11 
12 namespace tvm
13 {
14 
15 namespace requirements
16 {
17 
42 #define ADD_REQUIREMENT(T, name, member) \
43 public: \
44  const T<Lightweight> & name() const { return member; } \
45  T<Lightweight> & name() { return member; } \
46  \
47 private: \
48  T<Lightweight> member; \
49  template<typename... Args> \
50  void build(const T<Lightweight> & m, const Args &... args) \
51  { \
52  static_assert(!check_args<T<Lightweight>, Args...>() && !check_args<T<!Lightweight>, Args...>(), \
53  #T " has already been specified"); \
54  member = m; \
55  build(args...); \
56  } \
57  template<typename... Args> \
58  void build(const T<!Lightweight> & m, const Args &... args) \
59  { \
60  static_assert(!check_args<T<Lightweight>, Args...>() && !check_args<T<!Lightweight>, Args...>(), \
61  #T " has already been specified"); \
62  member = m; \
63  build(args...); \
64  }
65 
70 template<bool Lightweight = true>
72 {
73 public:
81  template<typename... Args>
82  SolvingRequirementsBase(const Args &... args)
83  { build(args...); }
84 
85 private:
86  template<typename T, typename Arg0, typename... Args>
87  static constexpr bool check_args()
88  { return std::is_same<T, Arg0>::value || check_args<T, Args...>(); }
89 
90  template<typename T>
91  static constexpr bool check_args()
92  { return false; }
93 
94  ADD_REQUIREMENT(PriorityLevelBase, priorityLevel, priority_)
95  ADD_REQUIREMENT(WeightBase, weight, weight_)
96  ADD_REQUIREMENT(AnisotropicWeightBase, anisotropicWeight, aWeight_)
97  ADD_REQUIREMENT(ViolationEvaluationBase, violationEvaluation, evalType_)
98 
99  void build() {}
100 };
101 
103 {
105 };
106 
108 {
109 public:
113 
115  : SolvingRequirementsBase(req.priorityLevel(), req.weight(), req.anisotropicWeight(), req.violationEvaluation())
116  {}
117 };
118 
119 #undef ADD_REQUIREMENT
120 
121 } // namespace requirements
122 
123 } // namespace tvm
#define ADD_REQUIREMENT(T, name, member)
Definition: SolvingRequirements.h:42
Definition: SolvingRequirements.h:72
SolvingRequirementsBase(const Args &... args)
Definition: SolvingRequirements.h:82
Definition: SolvingRequirements.h:108
SolvingRequirementsWithCallbacks(const SolvingRequirementsWithCallbacks &)=delete
SolvingRequirementsWithCallbacks(const SolvingRequirements &req)
Definition: SolvingRequirements.h:114
SolvingRequirementsWithCallbacks & operator=(const SolvingRequirementsWithCallbacks &)=delete
Definition: SolvingRequirements.h:103
Definition: Clock.h:12