TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
Loading...
Searching...
No Matches
tec_message.hpp File Reference

Defines a flexible message type and helper functions for the tec namespace. More...

#include <any>
#include "tec/tec_def.hpp"
#include "tec/tec_status.hpp"
#include "tec/tec_signal.hpp"

Go to the source code of this file.

Classes

struct  tec::Payload
 A message used for RPC-style calls. More...
 

Typedefs

using tec::Message = std::any
 Type alias for a message that can hold any object.
 
using tec::Request = std::any
 Type alias for a request object that can hold any object.
 
using tec::Reply = std::any
 Type alias for a reply object that can hold any object.
 

Functions

Message Helper Functions

Utility functions for working with Message objects.

Message tec::nullmsg () noexcept
 Creates a null message.
 
bool tec::is_null (const Message &msg) noexcept
 Checks if a message is null.
 
auto tec::name (const Message &msg) noexcept
 Retrieves the type name of a message's content for registering the corresponding message handler.
 

Detailed Description

Defines a flexible message type and helper functions for the tec namespace.

Author
The Emacs Cat
Date
2025-09-17

Typedef Documentation

◆ Message

using tec::Message = typedef std::any

Type alias for a message that can hold any object.

Uses std::any to store arbitrary data types, intended for use in message passing systems, such as processing by a Worker in the tec library. The null message (empty std::any) is used to signal the Worker to exit its message loop.

◆ Reply

using tec::Reply = typedef std::any

Type alias for a reply object that can hold any object.

See also
Daemon::make_request()

◆ Request

using tec::Request = typedef std::any

Type alias for a request object that can hold any object.

See also
Daemon::make_request()

Function Documentation

◆ is_null()

bool tec::is_null ( const Message msg)
inlinenoexcept

Checks if a message is null.

Determines whether the provided Message is empty (has no value).

Parameters
msgThe Message to check.
Returns
bool True if the message is null, false otherwise.

◆ name()

auto tec::name ( const Message msg)
inlinenoexcept

Retrieves the type name of a message's content for registering the corresponding message handler.

Returns the type name of the object stored in the Message.

Parameters
msgThe Message whose type name is to be retrieved.
Returns
const char* The name of the type stored in the Message.
See also
Worker::register_handler().

◆ nullmsg()

Message tec::nullmsg ( )
inlinenoexcept

Creates a null message.

Returns an empty Message (std::any with no value) used to signal a Worker to exit its message loop.

Returns
Message A null message.