TVM  0.9.4
SingleSolvingRequirement.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <variant>
6 
8 
9 namespace tvm
10 {
11 
12 namespace requirements
13 {
14 
15 namespace abstract
16 {
17 
24 template<typename T, bool Lightweight = true>
25 class SingleSolvingRequirement : public std::conditional_t<Lightweight, std::monostate, internal::CallbackManager>
26 {
27  using Base = std::conditional_t<Lightweight, std::monostate, internal::CallbackManager>;
28 
29 public:
31  const T & value() const { return value_; }
32 
34  void value(const T & val)
35  {
36  value_ = val;
37  default_ = false;
38  if constexpr(!Lightweight)
39  {
40  Base::run();
41  }
42  }
43 
45  bool isDefault() const { return default_; }
46 
47 protected:
48  SingleSolvingRequirement(const T & val, bool isDefault) : default_(isDefault), value_(val) {}
49 
51  : value_(other.value()), default_(other.isDefault())
52  {}
53 
55  {
56  value_ = other.value();
57  default_ = other.isDefault();
58  return *this;
59  }
60 
62  {
63  value(val);
64  return *this;
65  }
66 
68  bool default_;
69 
70  T value_;
71 };
72 
73 } // namespace abstract
74 
75 } // namespace requirements
76 
77 } // namespace tvm
78 
79 #define TVM_DEFINE_LW_NON_LW_CONVERSION_OPERATORS(className, T, L) \
80  className(const className<!L> & other) : abstract::SingleSolvingRequirement<T, L>(other) {} \
81  className & operator=(const className<!L> & other) \
82  { \
83  abstract::SingleSolvingRequirement<T, L>::operator=(other); \
84  return *this; \
85  } \
86  className & operator=(const T & val) \
87  { \
88  abstract::SingleSolvingRequirement<T, L>::operator=(val); \
89  return *this; \
90  }
Definition: SingleSolvingRequirement.h:26
SingleSolvingRequirement(const T &val, bool isDefault)
Definition: SingleSolvingRequirement.h:48
bool isDefault() const
Definition: SingleSolvingRequirement.h:45
const T & value() const
Definition: SingleSolvingRequirement.h:31
SingleSolvingRequirement & operator=(const SingleSolvingRequirement< T, !Lightweight > &other)
Definition: SingleSolvingRequirement.h:54
T value_
Definition: SingleSolvingRequirement.h:70
void value(const T &val)
Definition: SingleSolvingRequirement.h:34
SingleSolvingRequirement & operator=(const T &val)
Definition: SingleSolvingRequirement.h:61
bool default_
Definition: SingleSolvingRequirement.h:68
SingleSolvingRequirement(const SingleSolvingRequirement< T, !Lightweight > &other)
Definition: SingleSolvingRequirement.h:50
Definition: Clock.h:12