Relation.hpp
1 #pragma once
2 
3 #include <State/Address.hpp>
4 #include <State/Value.hpp>
5 
6 #include <ossia/detail/nullable_variant.hpp>
7 #include <ossia/editor/expression/operators.hpp>
8 
9 #include <QString>
10 
11 namespace State
12 {
13 using RelationMember
14  = ossia::nullable_variant<State::Address, State::AddressAccessor, ossia::value>;
15 
16 SCORE_LIB_STATE_EXPORT QString toString(const RelationMember&);
17 
18 struct SCORE_LIB_STATE_EXPORT Relation
19 {
20  Relation() noexcept = default;
21  Relation(const Relation& other) noexcept
22  : lhs{other.lhs}
23  , op{other.op}
24  , rhs{other.rhs}
25  {
26  }
27 
28  Relation(Relation&& other) noexcept
29  : lhs{std::move(other.lhs)}
30  , op{other.op}
31  , rhs{std::move(other.rhs)}
32  {
33  }
34 
35  Relation& operator=(const Relation& other) noexcept
36  {
37  lhs = other.lhs;
38  op = other.op;
39  rhs = other.rhs;
40  return *this;
41  }
42  Relation& operator=(Relation&& other) noexcept
43  {
44  lhs = std::move(other.lhs);
45  op = other.op;
46  rhs = std::move(other.rhs);
47  return *this;
48  }
49 
50  Relation(RelationMember l, ossia::expressions::comparator o, RelationMember r)
51  : lhs{std::move(l)}
52  , op{o}
53  , rhs{std::move(r)}
54  {
55  }
56 
57  RelationMember lhs;
58  ossia::expressions::comparator op;
59  RelationMember rhs;
60 
61  friend bool operator==(const Relation& eq_lhs, const Relation& eq_rhs)
62  {
63  return eq_lhs.lhs == eq_rhs.lhs && eq_lhs.rhs == eq_rhs.rhs
64  && eq_lhs.op == eq_rhs.op;
65  }
66 };
67 
68 SCORE_LIB_STATE_EXPORT QString toString(const Relation&);
69 
70 struct SCORE_LIB_STATE_EXPORT Pulse
71 {
72  State::Address address;
73  friend bool operator==(const Pulse& lhs, const Pulse& rhs)
74  {
75  return lhs.address == rhs.address;
76  }
77 };
78 SCORE_LIB_STATE_EXPORT QString toString(const Pulse&);
79 SCORE_LIB_STATE_EXPORT const QMap<ossia::expressions::comparator, QString> opToString();
80 }
Definition: ClipMode.hpp:10
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33
The Address struct.
Definition: Address.hpp:58
Definition: Relation.hpp:71
Definition: Relation.hpp:19