Class ControlMessage

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

task_type – A string indicating the type of the task.

Returns

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

task_type – A string indicating the type of the task.

Returns

A json object describing the task.

const nlohmann::json &get_tasks() const

Get the tasks for the control message.

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

key – A string indicating the metadata key.

Returns

True if the metadata key exists, false otherwise.

const nlohmann::json &get_metadata() const

Get the metadata for the control message.

const nlohmann::json get_metadata(const std::string &key) const

Get the metadata value for the given key from the control message.

Parameters

key – A string indicating the metadata key.

Returns

A json object describing the metadata value.

const nlohmann::json list_metadata() const

Get all metadata keys for the control message.

Returns

A json object containing all metadata keys and values.

std::shared_ptr<MessageMeta> payload()

Set the payload object for the control message.

Parameters

payload – A shared pointer to the message payload.

void payload(const std::shared_ptr<MessageMeta> &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

task_type

Returns

Previous Class AddScoresStageBase
Next Class DataLoader
© Copyright 2023, NVIDIA. Last updated on Feb 2, 2024.