New 4DSSE Code 0.0.1a |

Loading...
Searching...
No Matches
DObject.h
Go to the documentation of this file.
1#ifndef DOBJECT_H
2#define DOBJECT_H
3
4#include "Metadata.h"
5#include <variant>
6#include <memory>
7#include <vector>
8#include <string>
9#include <mutex>
10#include <map>
11#include <functional>
12
21
29 class DObject {
30 public:
37 using DataType = std::variant<
38 int, float, double, std::string, std::monostate,
39 std::vector<int>, std::vector<float>, std::vector<double>
40 >;
41
47 using Plugin = std::function<void(DObject&)>;
48
54 DObject();
55
62 DObject(const DataType& data, const Metadata& metadata);
63
71 const DataType& getData() const noexcept;
72
80 void setData(const DataType& data);
81
90 const Metadata& getMetadata() const noexcept;
91
99 void setMetadata(const Metadata& metadata);
100
108 void setDebugging(bool enableDebug);
109
115 [[nodiscard]] bool isDebuggingEnabled() const noexcept;
116
125 void registerPlugin(const std::string& id, Plugin plugin);
126
134 void unregisterPlugin(const std::string& id);
135
143 void runPlugin(const std::string& id);
144
150 void runAllPlugins();
151
161 friend std::ostream& operator<<(std::ostream& os, const DObject& obj);
162
163private:
164 DataType data_;
165 Metadata metadata_;
166 bool debugEnabled_ = false;
167 std::map<std::string, Plugin> plugins_;
168};
169
170#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