Kanzi  3.9.4
Kanzi Engine API
kanzi::AbstractMessageType Class Reference

AbstractMessageType is a homogeneous message type handle to an existing message type. More...

#include <kanzi/core/message/abstract_message_type.hpp>

Public Types

using ArgumentsType = MessageArguments
 Alias for associated message arguments class. More...
 
using FunctionType = function< void(MessageArguments &)>
 Alias for compatible handler functions. More...
 

Public Member Functions

 AbstractMessageType ()=default
 Constructor. More...
 
 AbstractMessageType (string_view name)
 Constructor. More...
 
 AbstractMessageType (const AbstractMessageTypeDescriptor *descriptor)
 Constructor. More...
 
const AbstractMessageTypeDescriptorget () const
 Gets the AbstractMessageTypeDescriptor of the AbstractMessageType. More...
 
const MetaclassgetArgumentsMetaclass () const
 Gets the metaclass of the message arguments associated with a message type. More...
 
PropertyTypeEditorInfoSharedPtr getEditorInfo () const
 Gets the editor information for a message type. More...
 
string getName () const
 Gets the fully qualified name of a message type in the form "Class.MessageType". More...
 
MessageRouting getRouting () const
 Gets the message routing of a message type. More...
 
 operator bool () const
 

Friends

template<typename T >
class DynamicMessageType
 
template<typename T >
class MessageType
 
bool operator!= (const AbstractMessageType &left, const AbstractMessageType &right)
 
bool operator< (const AbstractMessageType &left, const AbstractMessageType &right)
 
bool operator== (const AbstractMessageType &left, const AbstractMessageType &right)
 

Detailed Description

AbstractMessageType is a homogeneous message type handle to an existing message type.

You can use AbstractMessageType to operate on message types when a message type and its arguments type are unknown or irrelevant. It is usually more convenient to pass AbstractMessageType as a function argument instead of specifying the exact message type with certain message arguments. MessageType has a converting operator to AbstractMessageType. This enables you to pass MessageType directly to functions taking AbstractMessageType argument.

You can query generic non-message arguments specific message type information from an instance of an AbstractMessageType. You can also dispatch messages from a node with an instance of AbstractMessageType. To add message handlers of specific type, you must construct a DynamicMessageType.

Examples

To construct an AbstractMessageType with a fully qualified message type name:

// Use the fully qualified name to create an AbstractMessageType object, which you can
// use to refer to an existing message type in the Kanzi message system.
// To see the fully qualified name for a message type in Kanzi Studio, in the Triggers
// window hover over the name of that message type.
AbstractMessageType messageType("ExampleNode2D.ExampleMessage");

To dispatch a message using the created AbstractMessageType:

// Initialize the message that you want to dispatch.
MessageArguments messageArguments;
// Use the interface of Node to dispatch messages using AbstractMessageType.
node->dispatchAbstractMessage(messageType, messageArguments);

Member Typedef Documentation

◆ ArgumentsType

Alias for associated message arguments class.

◆ FunctionType

Alias for compatible handler functions.

Constructor & Destructor Documentation

◆ AbstractMessageType() [1/3]

kanzi::AbstractMessageType::AbstractMessageType ( )
explicitdefault

Constructor.

Creates an empty AbstractMessageType instance.

◆ AbstractMessageType() [2/3]

kanzi::AbstractMessageType::AbstractMessageType ( string_view  name)
inlineexplicit

Constructor.

Creates an AbstractMessageType instance referring to an existing message type with the given name. If a message type with the given name does not already exist in the Kanzi message system, the created AbstractMessageType instance is empty.

Parameters
nameFully qualified name of the message type.

◆ AbstractMessageType() [3/3]

kanzi::AbstractMessageType::AbstractMessageType ( const AbstractMessageTypeDescriptor descriptor)
inlineexplicit

Constructor.

Creates an AbstractMessageType instance referring to the given descriptor. If passed descriptor is null, the created AbstractMessageType instance is empty.

Note
This constructor solves a special case, prefer to use the other overloads.
Parameters
descriptorThe descriptor for the message type.

Member Function Documentation

◆ get()

const AbstractMessageTypeDescriptor* kanzi::AbstractMessageType::get ( ) const
inline

◆ getEditorInfo()

PropertyTypeEditorInfoSharedPtr kanzi::AbstractMessageType::getEditorInfo ( ) const
inline

Gets the editor information for a message type.

Returns
The editor information for the message type.

◆ getName()

string kanzi::AbstractMessageType::getName ( ) const
inline

Gets the fully qualified name of a message type in the form "Class.MessageType".

Returns
The fully qualified name of the message type.

◆ getRouting()

MessageRouting kanzi::AbstractMessageType::getRouting ( ) const
inline

Gets the message routing of a message type.

Returns
MessageRouting mode of the message type.

◆ getArgumentsMetaclass()

const Metaclass* kanzi::AbstractMessageType::getArgumentsMetaclass ( ) const
inline

Gets the metaclass of the message arguments associated with a message type.

Returns
The Metaclass pointer of the message arguments associated with the AbstractMessageType.

◆ operator bool()

kanzi::AbstractMessageType::operator bool ( ) const
inlineexplicit

Friends And Related Function Documentation

◆ MessageType

template<typename T >
friend class MessageType
friend

◆ DynamicMessageType

template<typename T >
friend class DynamicMessageType
friend

◆ operator==

bool operator== ( const AbstractMessageType left,
const AbstractMessageType right 
)
friend

◆ operator!=

bool operator!= ( const AbstractMessageType left,
const AbstractMessageType right 
)
friend

◆ operator<

bool operator< ( const AbstractMessageType left,
const AbstractMessageType right 
)
friend

The documentation for this class was generated from the following file: