New 4DSSE Code 0.0.1a
 
Loading...
Searching...
No Matches
DObject Class Reference

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 DataTypegetData () const noexcept
 Retrieves the data stored in the DObject.
 
void setData (const DataType &data)
 Sets the data for the DObject.
 
const MetadatagetMetadata () 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.
 

Detailed Description

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.

Member Typedef Documentation

◆ DataType

Initial value:
std::variant<
int, float, double, std::string, std::monostate,
std::vector<int>, std::vector<float>, std::vector<double>
>

Supported data types for the DObject.

This type alias uses std::variant to store different types of data, ensuring type safety and flexibility.

◆ Plugin

using DObject::Plugin = std::function<void(DObject&)>

Placeholder type for plugins.

In the future, this will be replaced with a concrete interface.

Constructor & Destructor Documentation

◆ DObject() [1/2]

DObject::DObject ( )

Default constructor.

Creates an empty DObject with default metadata.

◆ DObject() [2/2]

DObject::DObject ( const DataType & data,
const Metadata & metadata )

Constructor to initialize a DObject with data and metadata.

Parameters
dataThe data to be stored in the DObject.
metadataMetadata describing the stored data.

Member Function Documentation

◆ getData()

const DObject::DataType & DObject::getData ( ) const
noexcept

Retrieves the data stored in the DObject.

Use the appropriate type (matching the stored data) with std::get<T>().

Returns
A constant reference to the stored data.

◆ getMetadata()

const Metadata & DObject::getMetadata ( ) const
noexcept

Retrieves the metadata associated with the DObject.

The metadata provides essential information about the stored data, such as its type, size, and dimensions.

Returns
A constant reference to the metadata.

◆ isDebuggingEnabled()

bool DObject::isDebuggingEnabled ( ) const
nodiscardnoexcept

Checks if debugging is enabled for the DObject.

Returns
True if debugging is enabled, false otherwise.

◆ registerPlugin()

void DObject::registerPlugin ( const std::string & id,
Plugin plugin )

Registers a plugin with the DObject.

Plugins are stored in a registry and can add custom functionality to the DObject.

Parameters
idA unique identifier for the plugin.
pluginThe plugin function to register.

◆ runAllPlugins()

void DObject::runAllPlugins ( )

Executes all registered plugins in the registry.

Iterates through all plugins and invokes them on the current DObject.

◆ runPlugin()

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.

Parameters
idThe unique identifier of the plugin to execute.

◆ setData()

void DObject::setData ( const DataType & data)

Sets the data for the DObject.

Updates the stored data and optionally updates metadata.

Parameters
dataThe new data to store in the DObject.

◆ setDebugging()

void DObject::setDebugging ( bool enableDebug)

Enables or disables debugging and tracing for the DObject.

When debugging is enabled, the DObject tracks creation and modification history.

Parameters
enableDebugTrue to enable debugging, false to disable it.

◆ setMetadata()

void DObject::setMetadata ( const Metadata & metadata)

Updates the metadata for the DObject.

Use this function carefully to ensure consistency between the data and metadata.

Parameters
metadataThe new metadata to associate with the DObject.

◆ unregisterPlugin()

void DObject::unregisterPlugin ( const std::string & id)

Unregisters a plugin by its identifier.

Removes the plugin from the registry if it exists.

Parameters
idThe unique identifier of the plugin to unregister.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const DObject & obj )
friend

Provides a human-readable summary of the DObject.

Useful for quick inspection or logging during debugging sessions.

Parameters
osThe output stream to write to.
objThe DObject to summarize.
Returns
A reference to the output stream.

The documentation for this class was generated from the following files: