Factory for creating graphical circuit components.
More...
#include <gui_component_factory.hpp>
Factory for creating graphical circuit components.
The GUIComponentFactory implements a registry pattern for creating GraphicalComponent instances by type name. It supports registration of custom component types and provides a singleton instance for global access.
Components are registered via registerType() and created via create(). This allows for extensible component libraries without modifying the core factory code.
- See also
- GraphicalComponent
-
GraphicalLogicComponent
Definition at line 55 of file gui_component_factory.hpp.
◆ Factory
Factory function type for creating components.
- Parameters
-
| parent | Optional parent graphics item |
- Returns
- Unique pointer to created component
Definition at line 63 of file gui_component_factory.hpp.
◆ GUIComponentFactory()
◆ availableTypes()
| std::vector< std::string > availableTypes |
( |
| ) |
const |
◆ create()
Creates a component by type name.
- Parameters
-
| type | The type identifier |
| parent | Optional parent graphics item |
- Returns
- Unique pointer to created component
- Exceptions
-
| std::runtime_error | if type is unknown |
Definition at line 61 of file gui_component_factory.cpp.
◆ createForCoreType()
| std::unique_ptr< GraphicalComponent > createForCoreType |
( |
std::string_view | coreType, |
|
|
QGraphicsItem * | parent = nullptr ) const |
Creates the graphical component registered for a core component type.
- Parameters
-
| coreType | The core component type identifier |
| parent | Optional parent graphics item |
- Returns
- Unique pointer to the matching graphical component
- Exceptions
-
| std::runtime_error | if no graphical type, or more than one graphical type, is registered for the core type |
Definition at line 72 of file gui_component_factory.cpp.
◆ empty()
Creates an empty factory without registered types.
- Returns
- New empty factory instance
Definition at line 26 of file gui_component_factory.cpp.
◆ hasType()
| bool hasType |
( |
std::string_view | type | ) |
const |
◆ instance()
◆ metadata()
◆ registerType() [1/2]
| void registerType |
( |
std::string | type, |
|
|
Factory | factory ) |
Registers a component type.
- Parameters
-
| type | The type identifier string |
| factory | The factory function |
- Exceptions
-
| std::logic_error | if type is already registered |
Definition at line 37 of file gui_component_factory.cpp.
◆ registerType() [2/2]
◆ factories
| std::map<std::string, Entry, std::less<> > factories |
|
private |
The documentation for this class was generated from the following files: