Tatooine
toggleable.h
Go to the documentation of this file.
1#ifndef TATOOINE_FLOWEXPLORER_TOGGLEABLE_H
2#define TATOOINE_FLOWEXPLORER_TOGGLEABLE_H
3//==============================================================================
5//==============================================================================
6struct toggleable {
7 private:
8 bool m_active;
9
10 public:
11 explicit constexpr toggleable(bool active = true) : m_active{active} {}
12 constexpr toggleable(toggleable const &) = default;
13 constexpr toggleable(toggleable &&) = default;
14 constexpr auto operator=(toggleable const &) -> toggleable& = default;
15 constexpr auto operator=(toggleable &&) -> toggleable& = default;
16 ~toggleable() = default;
17
18 constexpr virtual auto set_active(bool active = true) -> void {
19 m_active = active;
20 }
21 constexpr auto activate() -> void { set_active(true); }
22 constexpr auto deactivate() -> void { set_active(false); }
23 constexpr auto toggle() -> void { set_active(!is_active()); }
24 constexpr auto is_active() const -> bool const & { return m_active; }
25 constexpr auto is_active() -> bool & { return m_active; }
26};
27//==============================================================================
28} // namespace tatooine::flowexplorer
29//==============================================================================
30#endif
Definition: directories.h:6
Definition: toggleable.h:6
constexpr auto toggle() -> void
Definition: toggleable.h:23
constexpr toggleable(toggleable &&)=default
constexpr auto operator=(toggleable const &) -> toggleable &=default
constexpr auto is_active() -> bool &
Definition: toggleable.h:25
virtual constexpr auto set_active(bool active=true) -> void
Definition: toggleable.h:18
constexpr auto is_active() const -> bool const &
Definition: toggleable.h:24
constexpr auto deactivate() -> void
Definition: toggleable.h:22
constexpr auto operator=(toggleable &&) -> toggleable &=default
constexpr toggleable(bool active=true)
Definition: toggleable.h:11
constexpr toggleable(toggleable const &)=default
bool m_active
Definition: toggleable.h:8
constexpr auto activate() -> void
Definition: toggleable.h:21