state_machine_cpp
state_id.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_ID_H
6 #define STATE_MACHINE_CPP_STATE_ID_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  struct Id;
16  class Instance;
17  }
18 }
19 
20 
21 std::ostream& operator<<(std::ostream& t_os, const state_machine_cpp::State::Id& t_id);
22 
23 struct state_machine_cpp::State::Id : public Util::comparable<State::Id> {
24  const std::string m_name;
25  const std::size_t m_hash;
26 
27  friend class hash<State::Id>;
28 protected:
29  inline bool equals_to(const Id &t_rhs) const override;
30 public:
31  explicit Id(const char *t_name) noexcept;
32 
33  Id(const Id&) = delete;
34  Id(Id&&) = delete;
35  Id& operator=(const Id&) = delete;
36  Id& operator=(Id&&) = delete;
37 
38  inline const std::string& name() const;
39  State::Instance operator[](unsigned int t_layer) const;
40 };
41 
42 const std::string &state_machine_cpp::State::Id::name() const {
43  return m_name;
44 }
45 
47  return m_hash == t_rhs.m_hash;
48 }
49 
50 
51 #endif //STATE_MACHINE_CPP_STATE_ID_H
state_machine_cpp::State::Id
Definition: state_id.h:23
state_machine_cpp::Util::comparable
Definition: __comparable.h:11
state_machine_cpp::State::Id::equals_to
bool equals_to(const Id &t_rhs) const override
Definition: state_id.h:46
state_machine_cpp::State::Id::m_name
const std::string m_name
Definition: state_id.h:24
operator<<
std::ostream & operator<<(std::ostream &t_os, const state_machine_cpp::State::Id &t_id)
state_machine_cpp::State::Instance
Definition: state_instance.h:23
state_machine_cpp
Definition: algorithm.h:14
__comparable.h
state_machine_cpp::State::Id::m_hash
const std::size_t m_hash
Definition: state_id.h:25
state_machine_cpp::hash
Definition: __hash.h:10
state_machine_cpp::State::Id::name
const std::string & name() const
Definition: state_id.h:42