wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementInfo< T > Struct Template Reference

Self-registering element information trait. More...

Detailed Description

template<typename T>
struct ElementInfo< T >

Self-registering element information trait.

Specializations must define:

The registered initializer performs both metadata and factory registration.

Example:

template<>
struct ElementInfo<And> {
static constexpr ElementConstraints constraints{
.type = ElementType::And,
.group = ElementGroup::Gate,
.minInputSize = 2, .maxInputSize = 8,
.minOutputSize = 1, .maxOutputSize = 1,
.canChangeAppearance = true,
};
static_assert(validate(constraints));
static ElementMetadata metadata() {
auto meta = metadataFromConstraints(constraints);
meta.pixmapPath = []{ return QStringLiteral(":/path.svg"); };
meta.titleText = QT_TRANSLATE_NOOP("And", "AND");
meta.translatedName = QT_TRANSLATE_NOOP("And", "And");
meta.trContext = "And";
meta.defaultAppearances = {":/path.svg"};
return meta;
}
static inline const bool registered = []() {
ElementFactory::registerCreator(constraints.type, [] { return new And(); });
return true;
}();
};
ElementMetadata metadataFromConstraints(const ElementConstraints &c)
Converts ElementConstraints to an ElementMetadata with all constraint-derived fields set.
Definition ElementInfo.h:80
constexpr bool validate(const ElementConstraints &c)
Validates element constraints at compile time.
Definition ElementInfo.h:48
Graphical representation of an AND gate (2–8 inputs, 1 output).
Definition And.h:17
static void registerCreator(ElementType type, std::function< GraphicElement *()> creator)
Registers a creator lambda for type, used by buildElement().
static void registerMetadata(const ElementMetadata &meta)
Registers meta in the global map (called once per element type at startup).
Compile-time-validatable subset of ElementMetadata.
Definition ElementInfo.h:21
Self-registering element information trait.
Compile-time-registered properties for one element type.

Definition at line 145 of file ElementInfo.h.


The documentation for this struct was generated from the following file: