SILICON
Loading...
Searching...
No Matches
circuitDocument.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 <cstdint>
21#include <string_view>
22#include <vector>
23
24#include <nlohmann/json_fwd.hpp>
25
26#include <core/circuit.hpp>
27
28namespace SILICON::core {
29
31
33[[nodiscard]] uint64_t deserializePortId(const nlohmann::json& value);
34
36[[nodiscard]] uint64_t deserializeBoundaryPortId(const nlohmann::json& component);
37
41 std::vector<CircuitPort> inputs;
42 std::vector<CircuitPort> outputs;
43};
44
53public:
54 virtual ~CircuitResolver() = default;
55
56 [[nodiscard]] virtual SubcircuitDefinition resolve(std::string_view slug) const = 0;
57};
58
63[[nodiscard]] Circuit
64deserializeCircuitDocument(std::string_view contents, const ComponentRegistry& registry,
65 const CircuitResolver* resolver = nullptr);
66
72[[nodiscard]] SubcircuitDefinition
73parseCircuitDocument(std::string_view contents, const ComponentRegistry& registry,
74 const CircuitResolver* resolver = nullptr);
75
76} // namespace SILICON::core
virtual ~CircuitResolver()=default
virtual SubcircuitDefinition resolve(std::string_view slug) const =0
Represents a digital circuit as a directed graph of components.
Definition circuit.hpp:125
SubcircuitDefinition parseCircuitDocument(const std::string_view contents, const ComponentRegistry &registry, const CircuitResolver *resolver)
Circuit deserializeCircuitDocument(const std::string_view contents, const ComponentRegistry &registry, const CircuitResolver *resolver)
uint64_t deserializePortId(const nlohmann::json &value)
uint64_t deserializeBoundaryPortId(const nlohmann::json &component)
std::vector< CircuitPort > inputs
std::vector< CircuitPort > outputs