Loading...
Searching...
No Matches
DObject.h
Go to the documentation of this file.
#ifndef DOBJECT_H
#define DOBJECT_H
#include "Metadata.h"
#include <variant>
#include <memory>
#include <vector>
#include <string>
#include <mutex>
#include <map>
#include <functional>
class DObject {
public:
using DataType = std::variant<
int, float, double, std::string, std::monostate,
std::vector<int>, std::vector<float>, std::vector<double>
>;
using Plugin = std::function<void(DObject&)>;
DObject();
DObject(const DataType& data, const Metadata& metadata);
const DataType& getData() const noexcept;
void setData(const DataType& data);
const Metadata& getMetadata() const noexcept;
void setMetadata(const Metadata& metadata);
void setDebugging(bool enableDebug);
[[nodiscard]] bool isDebuggingEnabled() const noexcept;
void registerPlugin(const std::string& id, Plugin plugin);
void unregisterPlugin(const std::string& id);
void runPlugin(const std::string& id);
void runAllPlugins();
friend std::ostream& operator<<(std::ostream& os, const DObject& obj);
private:
DataType data_;
Metadata metadata_;
bool debugEnabled_ = false;
std::map<std::string, Plugin> plugins_;
};
#endif // DOBJECT_H
Metadata.h
Public interface for the Metadata class used in the dobj module.
DObject::DObject
DObject()
Default constructor.
Definition DObject.cpp:13
DObject::runAllPlugins
void runAllPlugins()
Executes all registered plugins in the registry.
Definition DObject.cpp:99
DObject::getMetadata
const Metadata & getMetadata() const noexcept
Retrieves the metadata associated with the DObject.
Definition DObject.cpp:41
DObject::registerPlugin
void registerPlugin(const std::string &id, Plugin plugin)
Registers a plugin with the DObject.
Definition DObject.cpp:69
DObject::setMetadata
void setMetadata(const Metadata &metadata)
Updates the metadata for the DObject.
Definition DObject.cpp:48
DObject::getData
const DataType & getData() const noexcept
Retrieves the data stored in the DObject.
Definition DObject.cpp:26
DObject::setDebugging
void setDebugging(bool enableDebug)
Enables or disables debugging and tracing for the DObject.
Definition DObject.cpp:55
DObject::runPlugin
void runPlugin(const std::string &id)
Executes a plugin by its identifier.
Definition DObject.cpp:88
DObject::unregisterPlugin
void unregisterPlugin(const std::string &id)
Unregisters a plugin by its identifier.
Definition DObject.cpp:79
DObject::setData
void setData(const DataType &data)
Sets the data for the DObject.
Definition DObject.cpp:33
DObject::DataType
std::variant< int, float, double, std::string, std::monostate, std::vector< int >, std::vector< float >, std::vector< double > > DataType
Supported data types for the DObject.
Definition DObject.h:37
DObject::isDebuggingEnabled
bool isDebuggingEnabled() const noexcept
Checks if debugging is enabled for the DObject.
Definition DObject.cpp:62
DObject::Plugin
std::function< void(DObject &)> Plugin
Placeholder type for plugins.
Definition DObject.h:47
Metadata
Represents metadata information for data objects in the dobj module.
Definition Metadata.h:31