Class ControlMessage
Defined in File control.hpp
-
class ControlMessage
Class representing a control message for coordinating data processing tasks.
This class contains configuration information, task definitions, and metadata, as well as a pointer to an associated message payload. It provides methods for accessing and modifying these elements of the control message.
Public Functions
- ControlMessage()
- ControlMessage(const nlohmann::json &config)
- ControlMessage(const ControlMessage &other)
-
void config(const nlohmann::json &config)
Set the configuration object for the control message.
- Parameters
config – A json object containing configuration information.
-
const nlohmann::json &config() const
Get the configuration object for the control message.
- Returns
A const reference to the json object containing configuration information.
-
void add_task(const std::string &task_type, const nlohmann::json &task)
Add a task of the given type to the control message.
- Parameters
task_type – A string indicating the type of the task.
task – A json object describing the task.
-
bool has_task(const std::string &task_type) const
Check if a task of the given type exists in the control message.
- Parameters
- Returns
task_type – A string indicating the type of the task.
True if a task of the given type exists, false otherwise.
-
const nlohmann::json remove_task(const std::string &task_type)
Remove and return a task of the given type from the control message.
- Parameters
- Returns
task_type – A string indicating the type of the task.
A json object describing the task.
-
void set_metadata(const std::string &key, const nlohmann::json &value)
Add a key-value pair to the metadata for the control message.
- Parameters
key – A string key for the metadata value.
value – A json object describing the metadata value.
-
bool has_metadata(const std::string &key) const
Check if a metadata key exists in the control message.
- Parameters
- Returns
key – A string indicating the metadata key.
True if the metadata key exists, false otherwise.
-
const nlohmann::json get_metadata(const std::string &key) const
Get the metadata value for the given key from the control message.
- Parameters
- Returns
key – A string indicating the metadata key.
A json object describing the metadata value.
-
std::shared_ptr<MessageMeta> payload()
Set the payload object for the control message.
- Parameters
payload – A shared pointer to the message payload.
Set the payload object.
- Parameters
payload –
-
ControlMessageType task_type()
Get the type of task associated with the control message.
- Returns
An enum value indicating the task type.
-
void task_type(ControlMessageType task_type)
Set the task type for the control message.
- Parameters
- Returns
task_type –