HAL
state_component.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
5  StateComponent::StateComponent(std::unique_ptr<GateTypeComponent> component, const std::string& state_identifier, const std::string& neg_state_identifier)
6  : m_component(std::move(component)), m_state_identifier(state_identifier), m_neg_state_identifier(neg_state_identifier)
7  {
8  }
9 
11  {
12  return m_type;
13  }
14 
16  {
17  return component->get_type() == m_type;
18  }
19 
20  std::vector<GateTypeComponent*> StateComponent::get_components(const std::function<bool(const GateTypeComponent*)>& filter) const
21  {
22  if (m_component != nullptr)
23  {
24  std::vector<GateTypeComponent*> res = m_component->get_components(filter);
25  if (filter)
26  {
27  if (filter(m_component.get()))
28  {
29  res.push_back(m_component.get());
30  }
31  }
32  else
33  {
34  res.push_back(m_component.get());
35  }
36 
37  return res;
38  }
39 
40  return {};
41  }
42 
43  const std::string& StateComponent::get_state_identifier() const
44  {
45  return m_state_identifier;
46  }
47 
48  void StateComponent::set_state_identifier(const std::string& state_identifier)
49  {
50  m_state_identifier = state_identifier;
51  }
52 
53  const std::string& StateComponent::get_neg_state_identifier() const
54  {
55  return m_neg_state_identifier;
56  }
57 
58  void StateComponent::set_neg_state_identifier(const std::string& neg_state_identifier)
59  {
60  m_neg_state_identifier = neg_state_identifier;
61  }
62 
63 } // namespace hal
virtual ComponentType get_type() const =0
const std::string & get_state_identifier() const
void set_state_identifier(const std::string &state_identifier)
ComponentType get_type() const override
static bool is_class_of(const GateTypeComponent *component)
const std::string & get_neg_state_identifier() const
std::vector< GateTypeComponent * > get_components(const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const override
StateComponent(std::unique_ptr< GateTypeComponent > component, const std::string &state_identifier, const std::string &neg_state_identifier)
void set_neg_state_identifier(const std::string &neg_state_identifier)