state_machine_cpp
state_instance.h
Go to the documentation of this file.
1
//
2
// Created by henri on 27/04/21.
3
//
4
5
#ifndef STATE_MACHINE_CPP_STATE_INSTANCE_H
6
#define STATE_MACHINE_CPP_STATE_INSTANCE_H
7
8
#include <iostream>
9
#include "
impl/__comparable.h
"
10
11
namespace
state_machine_cpp
{
12
template
<
class
>
class
hash;
13
14
namespace
State {
15
class
Instance;
16
class
Id;
17
}
18
}
19
20
21
std::ostream&
operator<<
(std::ostream& t_os,
const
state_machine_cpp::State::Instance
& t_id);
22
23
class
state_machine_cpp::State::Instance
:
public
Util::comparable
<State::Instance> {
24
25
const
State::Id
* m_id =
nullptr
;
26
unsigned
int
m_layer = 0;
27
std::size_t m_hash = 0;
28
29
void
update_hash();
30
friend
struct
hash
<State::
Instance
>;
31
protected
:
32
bool
equals_to
(const Instance &t_rhs) const override;
33
public
:
34
Instance
() = default;
35
Instance
(const Id& t_id, unsigned int t_layer);
36
Instance
(const Id& t_id);
// NOLINT(google-explicit-constructor)
37
Instance
& operator=(const Id& t_rhs);
38
Instance
& operator=(const Instance&) = default;
39
40
std::string
name
() const;
41
inline const
State::Id
&
id
() const;
42
inline unsigned int
layer
() const;
43
};
44
45
const
state_machine_cpp::State::Id
&
state_machine_cpp::State::Instance::id
() const {
46
if
(!m_id) {
47
throw
std::runtime_error(
"Trying to get State::Id on an undefined state."
);
48
}
49
return
*m_id;
50
}
51
52
unsigned
int
state_machine_cpp::State::Instance::layer
()
const
{
53
return
m_layer;
54
}
55
56
57
#endif //STATE_MACHINE_CPP_STATE_INSTANCE_H
state_machine_cpp::State::Id
Definition:
state_id.h:23
state_machine_cpp::State::Instance::equals_to
bool equals_to(const Instance &t_rhs) const override
state_machine_cpp::State::Instance::id
const State::Id & id() const
Definition:
state_instance.h:45
state_machine_cpp::Util::comparable
Definition:
__comparable.h:11
state_machine_cpp::State::Instance::name
std::string name() const
state_machine_cpp::State::Instance
Definition:
state_instance.h:23
state_machine_cpp
Definition:
algorithm.h:14
__comparable.h
state_machine_cpp::State::Instance::layer
unsigned int layer() const
Definition:
state_instance.h:52
operator<<
std::ostream & operator<<(std::ostream &t_os, const state_machine_cpp::State::Instance &t_id)
state_machine_cpp::hash
Definition:
__hash.h:10
state_machine_cpp
include
states
state_instance.h
Generated by
1.8.17