A universal data container class. More...
#include <DObject.h>
Public Types | |
| using | DataType |
| Supported data types for the DObject. | |
| using | Plugin = std::function<void(DObject&)> |
| Placeholder type for plugins. | |
Public Member Functions | |
| DObject () | |
| Default constructor. | |
| DObject (const DataType &data, const Metadata &metadata) | |
| Constructor to initialize a DObject with data and metadata. | |
| const DataType & | getData () const noexcept |
| Retrieves the data stored in the DObject. | |
| void | setData (const DataType &data) |
| Sets the data for the DObject. | |
| const Metadata & | getMetadata () const noexcept |
| Retrieves the metadata associated with the DObject. | |
| void | setMetadata (const Metadata &metadata) |
| Updates the metadata for the DObject. | |
| void | setDebugging (bool enableDebug) |
| Enables or disables debugging and tracing for the DObject. | |
| bool | isDebuggingEnabled () const noexcept |
| Checks if debugging is enabled for the DObject. | |
| void | registerPlugin (const std::string &id, Plugin plugin) |
| Registers a plugin with the DObject. | |
| void | unregisterPlugin (const std::string &id) |
| Unregisters a plugin by its identifier. | |
| void | runPlugin (const std::string &id) |
| Executes a plugin by its identifier. | |
| void | runAllPlugins () |
| Executes all registered plugins in the registry. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const DObject &obj) |
| Provides a human-readable summary of the DObject. | |
A universal data container class.
The DObject class is designed to store arbitrary data alongside descriptive metadata. It supports plugin registration to allow extensible functionality.
| using DObject::DataType |
Supported data types for the DObject.
This type alias uses std::variant to store different types of data, ensuring type safety and flexibility.
| using DObject::Plugin = std::function<void(DObject&)> |
Placeholder type for plugins.
In the future, this will be replaced with a concrete interface.
| DObject::DObject | ( | ) |
Default constructor.
Creates an empty DObject with default metadata.
|
noexcept |
Retrieves the data stored in the DObject.
Use the appropriate type (matching the stored data) with std::get<T>().
|
noexcept |
Retrieves the metadata associated with the DObject.
The metadata provides essential information about the stored data, such as its type, size, and dimensions.
|
nodiscardnoexcept |
Checks if debugging is enabled for the DObject.
| void DObject::registerPlugin | ( | const std::string & | id, |
| Plugin | plugin ) |
| void DObject::runAllPlugins | ( | ) |
Executes all registered plugins in the registry.
Iterates through all plugins and invokes them on the current DObject.
| void DObject::runPlugin | ( | const std::string & | id | ) |
Executes a plugin by its identifier.
Invokes the registered plugin function. If the plugin is not found, no action is taken.
| id | The unique identifier of the plugin to execute. |
| void DObject::setData | ( | const DataType & | data | ) |
| void DObject::setDebugging | ( | bool | enableDebug | ) |
| void DObject::setMetadata | ( | const Metadata & | metadata | ) |
| void DObject::unregisterPlugin | ( | const std::string & | id | ) |
Unregisters a plugin by its identifier.
Removes the plugin from the registry if it exists.
| id | The unique identifier of the plugin to unregister. |
|
friend |