SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
propertyeditorregistry.h
Go to the documentation of this file.
1
24#ifndef PROPERTYEDITORREGISTRY_H
25#define PROPERTYEDITORREGISTRY_H
26
27#include <QHash>
28#include <QString>
29#include <functional>
30#include <memory>
31
32#include "ipropertyeditor.h"
33
44{
45public:
46 using Factory = std::function<std::unique_ptr<IPropertyEditor>()>;
47
50
58 void registerFactory(const QString &kind, Factory factory);
59
61 [[nodiscard]] bool hasFactory(const QString &kind) const;
62
69 [[nodiscard]] std::unique_ptr<IPropertyEditor> create(const QString &kind) const;
70
72 void clear();
73
74private:
75 PropertyEditorRegistry() = default;
77 PropertyEditorRegistry &operator=(const PropertyEditorRegistry &) = delete;
78
79 QHash<QString, Factory> m_factories;
80};
81
82#endif // PROPERTYEDITORREGISTRY_H
Process-wide dispatch table from editor kind → factory.
Definition propertyeditorregistry.h:44
static PropertyEditorRegistry & instance()
Access the singleton.
Definition propertyeditorregistry.cpp:11
std::unique_ptr< IPropertyEditor > create(const QString &kind) const
Build a fresh editor instance for kind, or nullptr if no factory is registered. Callers are responsib...
Definition propertyeditorregistry.cpp:43
bool hasFactory(const QString &kind) const
True when at least one factory is registered for kind.
Definition propertyeditorregistry.cpp:37
void registerFactory(const QString &kind, Factory factory)
Register a factory for an editor kind. Idempotent on the same (kind, factory) pair; replacing an exis...
Definition propertyeditorregistry.cpp:17
std::function< std::unique_ptr< IPropertyEditor >()> Factory
Definition propertyeditorregistry.h:46
void clear()
Drop every registration. Test-only helper.
Definition propertyeditorregistry.cpp:51
TokenKind kind
Definition queryparser.cpp:34