Maki
Loading...
Searching...
No Matches
region.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_HPP
8#define MAKI_REGION_HPP
9
10#include "detail/impl.hpp"
11#include <utility>
12
13namespace maki
14{
15
22template<class Impl>
23class region
24{
25public:
26#ifndef MAKI_DETAIL_DOXYGEN
27 template<class... Args>
28 region(Args&&... args):
29 impl_(this, std::forward<Args>(args)...)
30 {
31 }
32#endif
33
34 region(const region&) = delete;
35 region(region&&) = delete;
36 region& operator=(const region&) = delete;
37 region& operator=(region&&) = delete;
38 ~region() = default;
39
43 template<const auto& StateBuilder>
44 [[nodiscard]] bool is() const
45 {
46 return impl_.template is<StateBuilder>();
47 }
48
53 template<const auto& StateBuilder>
54 [[nodiscard]] const auto& state() const
55 {
56 return impl_.template state<StateBuilder>();
57 }
58
62#ifdef MAKI_DETAIL_DOXYGEN
64#else
65 static constexpr auto path()
66#endif
67 {
68 return Impl::path();
69 }
70
71private:
72 using impl_type = Impl;
73
74 MAKI_DETAIL_FRIENDLY_IMPL
75};
76
77} //namespace
78
79#endif
Encodes a path to a state or region.
Definition path.hpp:24
bool is() const
Returns whether the state created by StateBuilder is active.
Definition region.hpp:44
const auto & state() const
Returns the maki::state object created by StateBuilder (of type maki::state_builder).
Definition region.hpp:54
static constexpr maki::path< IMPLEMENTATION_DETAIL > path()
Returns the path to the region.
Definition region.hpp:63
The Maki library.