HAL  v4.5.0-254-g8f9f6a423
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
state_component.cpp
Go to the documentation of this file.
2 
3 #include <memory>
4 
5 namespace hal
6 {
7  StateComponent::StateComponent(std::unique_ptr<GateTypeComponent> component, const std::string& state_identifier, const std::string& neg_state_identifier)
8  : m_component(std::move(component)), m_state_identifier(state_identifier), m_neg_state_identifier(neg_state_identifier)
9  {
10  }
11 
12  std::unique_ptr<StateComponent> StateComponent::create(std::unique_ptr<GateTypeComponent> component, const std::string& state_identifier, const std::string& neg_state_identifier)
13  {
14  return std::unique_ptr<StateComponent>(new StateComponent(std::move(component), state_identifier, neg_state_identifier));
15  }
16 
17  StateComponent::ComponentType StateComponent::get_type() const
18  {
19  return m_type;
20  }
21 
22  bool StateComponent::is_class_of(const GateTypeComponent* component)
23  {
24  return component->get_type() == m_type;
25  }
26 
27  std::vector<GateTypeComponent*> StateComponent::get_components(const std::function<bool(const GateTypeComponent*)>& filter) const
28  {
29  if (m_component != nullptr)
30  {
31  std::vector<GateTypeComponent*> res = m_component->get_components(filter);
32  if (filter)
33  {
34  if (filter(m_component.get()))
35  {
36  res.push_back(m_component.get());
37  }
38  }
39  else
40  {
41  res.push_back(m_component.get());
42  }
43 
44  return res;
45  }
46 
47  return {};
48  }
49 
50  const std::string& StateComponent::get_state_identifier() const
51  {
52  return m_state_identifier;
53  }
54 
55  void StateComponent::set_state_identifier(const std::string& state_identifier)
56  {
57  m_state_identifier = state_identifier;
58  }
59 
60  const std::string& StateComponent::get_neg_state_identifier() const
61  {
62  return m_neg_state_identifier;
63  }
64 
65  void StateComponent::set_neg_state_identifier(const std::string& neg_state_identifier)
66  {
67  m_neg_state_identifier = neg_state_identifier;
68  }
69 
70 } // namespace hal
virtual ComponentType get_type() const =0
Definition: defines.h:45