Loading...
Searching...
No Matches
VariantBasedNode.hpp
1#pragma once
2#include <score/model/tree/InvisibleRootNode.hpp>
3
4#include <ossia/detail/nullable_variant.hpp>
5
6namespace score
7{
8
21template <typename... Args>
23{
24public:
25 using variant_type = ossia::nullable_variant<InvisibleRootNode, Args...>;
26
27 VariantBasedNode(const VariantBasedNode& t) = default;
28 VariantBasedNode(VariantBasedNode&& t) noexcept = default;
29 VariantBasedNode& operator=(const VariantBasedNode& t) = default;
30
32 : m_data{InvisibleRootNode{}}
33 {
34 }
35
36 template <typename T>
37 VariantBasedNode(const T& t)
38 : m_data{t}
39 {
40 }
41
47 template <typename T>
48 bool is() const
49 {
50 return m_data.template target<T>() != nullptr;
51 }
52
53 template <typename T>
54 const T* target() const
55 {
56 return m_data.template target<T>();
57 }
58
59 template <typename T>
60 T* target()
61 {
62 return m_data.template target<T>();
63 }
64
65 template <typename T>
66 void set(const T& t)
67 {
68 m_data = t;
69 }
70
71 template <typename T>
72 const T& get() const
73 {
74 return *m_data.template target<T>();
75 }
76
77 template <typename T>
78 T& get()
79 {
80 return *m_data.template target<T>();
81 }
82
83 auto which() const { return m_data.which(); }
84
85 auto& impl() const { return m_data; }
86
87 auto& impl() { return m_data; }
88
89 bool operator==(const VariantBasedNode& other) const { return m_data == other.m_data; }
90
91protected:
92 ossia::nullable_variant<InvisibleRootNode, Args...> m_data;
93};
94}
The VariantBasedNode class.
Definition VariantBasedNode.hpp:23
bool is() const
is Checks the type of the node.
Definition VariantBasedNode.hpp:48
Base toolkit upon which the software is built.
Definition Application.cpp:90
The InvisibleRootNodeTag struct.
Definition InvisibleRootNode.hpp:11