Maki
Loading...
Searching...
No Matches
state.hpp
1//Copyright Florian Goujeon 2021 - 2025.
2//Distributed under the Boost Software License, Version 1.0.
3//(See accompanying file LICENSE or copy at
4//https://www.boost.org/LICENSE_1_0.txt)
5//Official repository: https://github.com/fgoujeon/maki
6
7#ifndef MAKI_REGION_STATE_HPP
8#define MAKI_REGION_STATE_HPP
9
10#include "detail/pretty_name.hpp"
11#include "detail/impl.hpp"
12#include <string_view>
13#include <utility>
14
15namespace maki
16{
17
24template<class Impl>
25class state
26{
27public:
28#ifndef MAKI_DETAIL_DOXYGEN
29 template<class... Args>
30 constexpr state(Args&&... args):
31 impl_(std::forward<Args>(args)...)
32 {
33 }
34#endif
35
36 state(const state&) = delete;
37 state(state&&) = delete;
38 state& operator=(const state&) = delete;
39 state& operator=(state&&) = delete;
40 ~state() = default;
41
47 template<const auto& StateBuilder>
48 [[nodiscard]] const auto& substate() const
49 {
50 return impl_.template state<StateBuilder>();
51 }
52
57 template<int Index>
58 [[nodiscard]] const auto& region() const
59 {
60 return impl_.template region<Index>();
61 }
62
67 template<const auto& StateBuilder>
68 [[nodiscard]] bool is() const
69 {
70 return impl_.template is<StateBuilder>();
71 }
72
76 [[nodiscard]] const auto& context() const
77 {
78 return impl_.context();
79 }
80
89 [[nodiscard]] static std::string_view pretty_name()
90 {
91 return detail::pretty_name<Impl::builder>();
92 }
93
94private:
95 using impl_type = Impl;
96
97 MAKI_DETAIL_FRIENDLY_IMPL
98};
99
100} //namespace
101
102#endif
bool is() const
Returns whether the state created by StateBuilder is active. Only valid if state is composite and onl...
Definition state.hpp:68
const auto & substate() const
Returns the maki::state object created by StateBuilder (of type maki::state_builder)....
Definition state.hpp:48
const auto & context() const
Returns the context instantiated at construction.
Definition state.hpp:76
const auto & region() const
Returns the maki::region object at index Index. Only valid if state is composite.
Definition state.hpp:58
static std::string_view pretty_name()
The pretty name of the state.
Definition state.hpp:89
The Maki library.