wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementMetadata.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <functional>
11
12#include <QMap>
13#include <QString>
14#include <QStringList>
15
16#include "App/Core/Enums.h"
17
28 ElementType type = ElementType::Unknown;
29 ElementGroup group = ElementGroup::Unknown;
30
31 // --- Display properties ---
32
33 std::function<QString()> pixmapPath;
34 const char *titleText = nullptr;
35 const char *translatedName = nullptr;
36 const char *trContext = nullptr;
37
38 // --- Port configuration ---
39
40 quint64 minInputSize = 0;
41 quint64 maxInputSize = 0;
42 quint64 minOutputSize = 0;
43 quint64 maxOutputSize = 0;
44
45 // --- Appearance configuration ---
46
47 QStringList defaultAppearances;
49
50 // --- Feature flags ---
51
52 bool canChangeAppearance = false;
53 bool hasColors = false;
54 bool hasAudio = false;
55 bool hasAudioBox = false;
56 bool hasTrigger = false;
57 bool hasFrequency = false;
58 bool hasDelay = false;
59 bool hasLabel = false;
60 bool hasTruthTable = false;
61 bool hasVolume = false;
62 bool rotatesGraphic = true;
63};
64
73{
74public:
76 static const ElementMetadata &metadata(ElementType type);
78 static void registerMetadata(const ElementMetadata &meta);
80 static bool hasMetadata(ElementType type);
81
82private:
84 static QMap<ElementType, ElementMetadata> &registry();
85};
Central enumeration types for element types, groups, and signal status.
Enums::ElementType ElementType
Definition Enums.h:107
Enums::ElementGroup ElementGroup
Definition Enums.h:108
Global registry of ElementMetadata, one entry per ElementType.
static bool hasMetadata(ElementType type)
Returns true if metadata has been registered for type.
static void registerMetadata(const ElementMetadata &meta)
Registers meta in the global map (called once per element type at startup).
static const ElementMetadata & metadata(ElementType type)
Returns the metadata for type. Asserts if type is not registered.
Compile-time-registered properties for one element type.
quint64 maxInputSize
Maximum number of input ports.
bool rotatesGraphic
True if rotating/flipping re-orients the graphic itself; false keeps the icon fixed and only repositi...
bool hasLabel
True if the element supports a user-editable label.
ElementGroup group
UI palette group this element belongs to.
bool hasAudioBox
True if the element shows an audio selection box.
quint64 maxOutputSize
Maximum number of output ports.
bool hasFrequency
True if the element exposes a configurable clock frequency.
QStringList defaultAppearances
Built-in appearance resource paths.
bool hasAudio
True if the element supports audio output.
QStringList alternativeAppearances
User-selectable alternative appearance paths.
bool hasColors
True if the element supports color selection.
bool hasDelay
True if the element exposes a configurable clock phase delay.
const char * trContext
Translation context string for QCoreApplication::translate().
bool hasVolume
True if the element supports volume control.
quint64 minInputSize
Minimum number of input ports.
const char * translatedName
Untranslated element name used for tooltips (QT_TRANSLATE_NOOP).
ElementType type
Unique element type identifier.
quint64 minOutputSize
Minimum number of output ports.
bool canChangeAppearance
True if the user can choose a custom appearance.
std::function< QString()> pixmapPath
Callable returning the default pixmap resource path (lazily evaluated).
bool hasTrigger
True if the element supports a keyboard trigger shortcut.
bool hasTruthTable
True if the element has an editable truth table.
const char * titleText
Untranslated title shown in the element palette (QT_TRANSLATE_NOOP).