tetengo 1.8.2
A multipurpose library set
Loading...
Searching...
No Matches
entry.hpp
Go to the documentation of this file.
1
7#if !defined(TETENGO_LATTICE_ENTRY_HPP)
8#define TETENGO_LATTICE_ENTRY_HPP
9
10#include <any>
11#include <memory>
12#include <utility>
13
15
16
17namespace tetengo::lattice
18{
19 class entry_view;
20
21
25 class entry
26 {
27 public:
28 // static functions
29
35 [[nodiscard]] static const entry& bos_eos();
36
37
38 // constructors
39
47 entry(std::unique_ptr<input>&& p_key, std::any value, int cost);
48
54 entry(const entry_view& view);
55
61 entry(const entry& another);
62
68 entry(entry&& another);
69
70
71 // functions
72
78 [[nodiscard]] const input* p_key() const;
79
85 [[nodiscard]] const std::any& value() const;
86
92 [[nodiscard]] int cost() const;
93
94
95 private:
96 // variables
97
98 std::unique_ptr<input> m_p_key;
99
100 std::any m_value;
101
102 int m_cost;
103 };
104
105
110 {
111 public:
112 // static functions
113
119 [[nodiscard]] static const entry_view& bos_eos();
120
121
122 // constructors
123
131 constexpr entry_view(const input* p_key, const std::any* value, int cost) :
132 m_p_key{ p_key },
133 m_value{ std::move(value) },
134 m_cost{ cost }
135 {}
136
143
144
145 // functions
146
152 [[nodiscard]] constexpr const input* p_key() const
153 {
154 return m_p_key;
155 }
156
162 [[nodiscard]] constexpr const std::any* value() const
163 {
164 return m_value;
165 }
166
172 [[nodiscard]] constexpr int cost() const
173 {
174 return m_cost;
175 }
176
177
178 private:
179 // variables
180
181 const input* m_p_key;
182
183 const std::any* m_value;
184
185 int m_cost;
186 };
187
188
189}
190
191
192#endif
An entry view.
Definition entry.hpp:110
constexpr const std::any * value() const
Returns the value.
Definition entry.hpp:162
constexpr const input * p_key() const
Returns the pointer to the key.
Definition entry.hpp:152
constexpr entry_view(const input *p_key, const std::any *value, int cost)
Creates an entry view.
Definition entry.hpp:131
static const entry_view & bos_eos()
Returns the BOS/EOS (Beginning/End of Sequence) entry.
constexpr int cost() const
Returns the cost.
Definition entry.hpp:172
entry_view(const entry &entry)
Creates an entry view.
An entry.
Definition entry.hpp:26
entry(const entry &another)
Copies an entry.
entry(entry &&another)
Moves an entry.
const input * p_key() const
Returns the pointer to the key.
entry(std::unique_ptr< input > &&p_key, std::any value, int cost)
Creates an entry.
entry(const entry_view &view)
Creates an entry.
static const entry & bos_eos()
Returns the BOS/EOS (Beginning/End of Sequence) entry.
const std::any & value() const
Returns the value.
int cost() const
Returns the cost.
An input.
Definition input.hpp:24
An input.
A lattice library.