SILICON
Loading...
Searching...
No Matches
gui_component_registration.cpp
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
19
20#include <core/flipflops.hpp>
21#include <core/gates.hpp>
22#include <core/io.hpp>
23#include <core/memory.hpp>
24#include <core/register.hpp>
38
39#include <utility>
40
41namespace SILICON::ui {
42using namespace SILICON::core;
43
45{
46 auto reg = [&factory](std::string name, auto factoryFunc) {
47 factory.registerType(std::move(name), std::move(factoryFunc));
48 };
49 auto regMapped = [&factory](std::string name, std::string coreType, auto factoryFunc) {
50 factory.registerType(std::move(name), std::move(factoryFunc),
51 {.coreType = std::move(coreType)});
52 };
53
54 factory.registerType(
56 [](QGraphicsItem* p) { return std::make_unique<GraphicalText>(p); },
57 {.coreType = {},
58 .graphicalMetadata = ComponentMetadata{.displayName = "Text",
59 .description = "Multiline text annotation",
60 .category = ComponentCategory::Utils}});
61
62 reg(std::string(AndGate::Type),
63 [](QGraphicsItem* p) { return std::make_unique<GraphicalAnd>(p); });
64 reg(std::string(OrGate::Type),
65 [](QGraphicsItem* p) { return std::make_unique<GraphicalOr>(p); });
66 reg(std::string(NotGate::Type),
67 [](QGraphicsItem* p) { return std::make_unique<GraphicalNot>(p); });
68 reg(std::string(NandGate::Type),
69 [](QGraphicsItem* p) { return std::make_unique<GraphicalNand>(p); });
70 reg(std::string(NorGate::Type),
71 [](QGraphicsItem* p) { return std::make_unique<GraphicalNor>(p); });
72 reg(std::string(XorGate::Type),
73 [](QGraphicsItem* p) { return std::make_unique<GraphicalXor>(p); });
74 reg(std::string(DFlipFlop::Type),
75 [](QGraphicsItem* p) { return std::make_unique<GraphicalDFlipFlop>(p); });
76 reg(std::string(EFlipFlop::Type),
77 [](QGraphicsItem* p) { return std::make_unique<GraphicalEFlipFlop>(p); });
78 reg(std::string(DLatch::Type),
79 [](QGraphicsItem* p) { return std::make_unique<GraphicalDLatch>(p); });
80 reg(std::string(JKFlipFlop::Type),
81 [](QGraphicsItem* p) { return std::make_unique<GraphicalJKFlipFlop>(p); });
82
83 reg(std::string(ConstantComponent::Type),
84 [](QGraphicsItem* p) { return std::make_unique<GraphicalConstant>(p); });
85
86 regMapped(std::string(GraphicalInput::COMPONENT_TYPE),
87 std::string(DummyInputComponent::Type),
88 [](QGraphicsItem* p) { return std::make_unique<GraphicalInput>(p); });
89 regMapped(std::string(GraphicalOutputSingle::COMPONENT_TYPE),
90 std::string(DummyOutputComponent::Type),
91 [](QGraphicsItem* p) { return std::make_unique<GraphicalOutputSingle>(p); });
92 regMapped(std::string(GraphicalBusInput::COMPONENT_TYPE),
94 [](QGraphicsItem* p) { return std::make_unique<GraphicalBusInput>(p); });
95 regMapped(std::string(GraphicalBusOutput::COMPONENT_TYPE),
97 [](QGraphicsItem* p) { return std::make_unique<GraphicalBusOutput>(p); });
98
99 reg(std::string(WireSplitter::Type),
100 [](QGraphicsItem* p) { return std::make_unique<GraphicalWireSplitter>(p); });
101 reg(std::string(WireMerger::Type),
102 [](QGraphicsItem* p) { return std::make_unique<GraphicalWireMerger>(p); });
103
104 reg(std::string(Extender::Type),
105 [](QGraphicsItem* p) { return std::make_unique<GraphicalExtender>(p); });
106 reg(std::string(Complementer::Type),
107 [](QGraphicsItem* p) { return std::make_unique<GraphicalComplementer>(p); });
108 reg(std::string(HalfAdder::Type),
109 [](QGraphicsItem* p) { return std::make_unique<GraphicalHalfAdder>(p); });
110 reg(std::string(FullAdder::Type),
111 [](QGraphicsItem* p) { return std::make_unique<GraphicalFullAdder>(p); });
112 reg(std::string(AdderNBits::Type),
113 [](QGraphicsItem* p) { return std::make_unique<GraphicalAdderNBits>(p); });
114 reg(std::string(Multiplier::Type),
115 [](QGraphicsItem* p) { return std::make_unique<GraphicalMultiplier>(p); });
116 reg(std::string(Divider::Type),
117 [](QGraphicsItem* p) { return std::make_unique<GraphicalDivider>(p); });
118 reg(std::string(Shifter::Type),
119 [](QGraphicsItem* p) { return std::make_unique<GraphicalShifter>(p); });
120 reg(std::string(Comparator::Type),
121 [](QGraphicsItem* p) { return std::make_unique<GraphicalComparator>(p); });
122 reg(std::string(Multiplexer::Type),
123 [](QGraphicsItem* p) { return std::make_unique<GraphicalMultiplexer>(p); });
124 reg(std::string(Demultiplexer::Type),
125 [](QGraphicsItem* p) { return std::make_unique<GraphicalDemultiplexer>(p); });
126 reg(std::string(Decoder::Type),
127 [](QGraphicsItem* p) { return std::make_unique<GraphicalDecoder>(p); });
128 reg(std::string(Register::Type),
129 [](QGraphicsItem* p) { return std::make_unique<GraphicalRegister>(p); });
130 reg(std::string(ROM::Type),
131 [](QGraphicsItem* p) { return std::make_unique<GraphicalROM>(p); });
132 reg(std::string(SubcircuitComponent::Type),
133 [](QGraphicsItem* p) { return std::make_unique<GraphicalSubcircuitComponent>(p); });
134}
135
136} // namespace SILICON::ui
static constexpr std::string_view Type
Definition gates.hpp:82
static constexpr std::string_view Type
Definition io.hpp:31
static constexpr std::string_view Type
Serialization/type-registry identifier.
static constexpr std::string_view Type
Serialization/type-registry identifier.
static constexpr std::string_view Type
Definition io.hpp:91
static constexpr std::string_view Type
Definition io.hpp:131
static constexpr std::string_view Type
Definition io.hpp:69
static constexpr std::string_view Type
Definition io.hpp:114
static constexpr std::string_view Type
Serialization/type-registry identifier.
static constexpr std::string_view Type
Serialization/type-registry identifier.
static constexpr std::string_view Type
Definition gates.hpp:132
static constexpr std::string_view Type
Definition gates.hpp:148
static constexpr std::string_view Type
Definition gates.hpp:117
static constexpr std::string_view Type
Definition gates.hpp:98
static constexpr std::string_view Type
Definition memory.hpp:32
static constexpr std::string_view Type
Definition register.hpp:31
static constexpr std::string_view Type
static constexpr std::string_view Type
Definition gates.hpp:164
static constexpr std::string_view Type
Serialization/type-registry identifier.
static constexpr std::string_view Type
static constexpr std::string_view Type
static constexpr std::string_view Type
static constexpr std::string_view Type
static constexpr std::string_view Type
static constexpr std::string_view Type
static constexpr std::string_view Type
Serialization/type-registry identifier.
static constexpr std::string_view Type
Serialization/type-registry identifier.
static constexpr std::string_view Type
static constexpr std::string_view Type
static constexpr std::string_view Type
static constexpr std::string_view Type
Definition utils.hpp:65
static constexpr std::string_view Type
Definition utils.hpp:36
Factory for creating graphical circuit components.
void registerType(std::string type, Factory factory)
Registers a component type.
static constexpr std::string_view COMPONENT_TYPE
static constexpr std::string_view COMPONENT_TYPE
static constexpr std::string_view COMPONENT_TYPE
static constexpr std::string_view COMPONENT_TYPE
static constexpr std::string_view COMPONENT_TYPE
void registerAllGUIComponents(GUIComponentFactory &factory)