SILICON
Toggle main menu visibility
Loading...
Searching...
No Matches
circuitTestHelpers.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026. Giulio Cocconi
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#pragma once
19
20
#include <algorithm>
21
#include <ranges>
22
#include <set>
23
#include <string>
24
#include <vector>
25
26
#include <boost/graph/graph_traits.hpp>
27
28
#include <
core/circuit.hpp
>
29
#include <
core/component.hpp
>
30
31
using namespace
SILICON::core
;
32
33
inline
std::vector<Component_ptr>
componentsIn
(
const
Circuit
& circuit)
34
{
35
std::vector<Component_ptr> components;
36
const
auto
& graph = circuit.
getGraph
();
37
components.reserve(boost::num_vertices(graph));
38
for
(
const
auto
vertex : boost::make_iterator_range(boost::vertices(graph))) {
39
if
(
auto
component = graph[vertex].component)
40
components.push_back(component);
41
}
42
return
components;
43
}
44
45
inline
std::multiset<std::string>
componentTypes
(
const
Circuit
& circuit)
46
{
47
auto
components =
componentsIn
(circuit);
48
std::multiset<std::string> result;
49
std::ranges::transform(
50
components, std::inserter(result, result.end()),
51
[](
const
Component_ptr
& component) { return std::string(component->typeName()); });
52
return
result;
53
}
componentTypes
std::multiset< std::string > componentTypes(const Circuit &circuit)
Definition
circuitTestHelpers.hpp:45
componentsIn
std::vector< Component_ptr > componentsIn(const Circuit &circuit)
Definition
circuitTestHelpers.hpp:33
circuit.hpp
SILICON::core::Circuit
Represents a digital circuit as a directed graph of components.
Definition
circuit.hpp:125
SILICON::core::Circuit::getGraph
const CircuitGraph & getGraph() const
Gets the underlying circuit graph.
Definition
circuit.hpp:349
component.hpp
SILICON::core
Definition
activeKeyGuard.hpp:28
SILICON::core::Component_ptr
std::shared_ptr< Component > Component_ptr
Definition
component_registry.hpp:33
tests
circuitTestHelpers.hpp
Generated by
1.17.0