Kanzi  3.9.6
Kanzi Engine API
kanzi::MessageType< TArguments > Class Template Reference

An instance of a MessageType represents a single message type in the Kanzi message system. More...

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

Public Types

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

Public Member Functions

const AbstractMessageTypeDescriptorget () const
 Gets the AbstractMessageTypeDescriptor of the message type. More...
 
PropertyTypeEditorInfoSharedPtr getEditorInfo () const
 Gets the editor information for the message type. More...
 
string getName () const
 Gets the fully qualified name of the message type in the form "Class.MessageType". More...
 
MessageRouting getRouting () const
 Gets the message routing of the message type. More...
 
 MessageType (FixedString name, MessageRouting routing, PropertyTypeEditorInfoSharedPtr editorInfo)
 Constructor. More...
 
 MessageType (MetadataGeneratedName name, MessageRouting routing, PropertyTypeEditorInfoSharedPtr editorInfo)
 Constructor. More...
 
 MessageType (FixedString name)
 Constructor. More...
 
 MessageType (MetadataGeneratedName name)
 Constructor. More...
 
 MessageType (FixedString name, PropertyTypeEditorInfoSharedPtr editorInfo)
 Constructor. More...
 
 MessageType (MetadataGeneratedName name, PropertyTypeEditorInfoSharedPtr editorInfo)
 Constructor. More...
 
 MessageType (const MessageType &)=delete
 Deleted copy constructor. More...
 
 operator AbstractMessageType () const
 Conversion operator to AbstractMessageType. More...
 
MessageTypeoperator= (const MessageType &)=delete
 Deleted assignment. More...
 
 ~MessageType ()
 Destructor. More...
 

Static Public Member Functions

static const MetaclassgetArgumentsMetaclass ()
 Gets the metaclass of the message arguments associated with the message type. More...
 
static constexpr bool hasCustomArgumentsClass ()
 Returns whether the message arguments class associated with the message type is a custom message arguments class or the base MessageArguments class. More...
 

Protected Member Functions

 MessageType ()=default
 Constructor. More...
 

Protected Attributes

const AbstractMessageTypeDescriptorm_descriptor
 Describes the name, routing, and message arguments metaclass of the message type. More...
 

Friends

class AbstractMessageType
 
template<typename T >
class DynamicMessageType
 

Detailed Description

template<class TArguments>
class kanzi::MessageType< TArguments >

An instance of a MessageType represents a single message type in the Kanzi message system.

A message type exists throughout the lifetime of an application.

To work with the existing message types in the Kanzi message system, use the DynamicMessageType and AbstractMessageType classes.

Examples

To declare a new message type:

// Define an example node, which introduces a new static message type to the Kanzi message system.
class ExampleNode2D : public EmptyNode2D
{
public:
// To introduce a static message type to the Kanzi message system, use the
// MessageType declaration in your class.
// For example, declare a message type whose arguments type is the base
// class of Kanzi message arguments, MessageArguments.
static MessageType<MessageArguments> ExampleMessage;
// In the Kanzi Engine register the ExampleNode2D derived from the Node2D and the
// ExampleMessage message type.
// For more information about the metadata system in Kanzi, see the Node and Metaclass classes.
KZ_METACLASS_BEGIN(ExampleNode2D, Node2D, "MyNamespace.ExampleNode2D")
KZ_METACLASS_MESSAGE_TYPE(ExampleMessage)
// ...

To define a new message type:

// In the ExampleNode2D node type define a message type whose message arguments type is the MessageArguments
// base class, is named "ExampleMessage", and has a fully qualified name "ExampleNode2D.ExampleMessage".
//
// For example, use these MessageType constructor arguments to define a message type:
// - The first argument sets the fully qualified name. For example, set the fully qualified
// name to "ExampleNode2D.ExampleMessage".
// - The second argument sets the message routing mode. This argument defines how messages
// of this type travel in the node tree. For more information on message dispatching, see Node.
// - The third argument sets the metadata for this message type that Kanzi Studio uses. For the list of all
// available metadata attributes in Kanzi documentation see Reference > Reference for showing Kanzi Engine
// plugin custom types in Kanzi Studio.
// - displayName sets a user-friendly name that users can see in the Triggers window in Kanzi Studio.
// - tooltip sets the text shown when users hover over the name of this message type in Kanzi Studio.
// - category sets the category where users can see the message in Kanzi Studio.
// If you do not want users to access a message type in Kanzi Studio, pass an empty
// PropertyTypeEditorInfoSharedPtr shared pointer.
MessageType<MessageArguments> ExampleNode2D::ExampleMessage(
kzMakeFixedString("ExampleNode2D.ExampleMessage"),
metadata.displayName = "Example message";
metadata.tooltip = "Message used as an example.";
metadata.category = "Examples";));
See also
For examples that demonstrate adding and removal of message handlers, or dispatching messages, see Node.

Member Typedef Documentation

◆ ArgumentsType

template<class TArguments>
using kanzi::MessageType< TArguments >::ArgumentsType = TArguments

Alias for associated message arguments class.

◆ FunctionType

template<class TArguments>
using kanzi::MessageType< TArguments >::FunctionType = function<void(ArgumentsType&)>

Alias for compatible handler functions.

Constructor & Destructor Documentation

◆ MessageType() [1/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( FixedString  name,
MessageRouting  routing,
PropertyTypeEditorInfoSharedPtr  editorInfo 
)
inlineexplicit

Constructor.

Parameters
nameFully qualified name for the message type as a FixedString.
routingMessage routing mode for the message type.
editorInfoSets the editor information for this message type that Kanzi Studio uses.

◆ MessageType() [2/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( MetadataGeneratedName  name,
MessageRouting  routing,
PropertyTypeEditorInfoSharedPtr  editorInfo 
)
inlineexplicit

Constructor.

Parameters
nameFully qualified name for the message type as a MetadataGeneratedName.
routingMessage routing mode for the message type.
editorInfoSets the editor information for this message type that Kanzi Studio uses.

◆ MessageType() [3/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( FixedString  name)
inlineexplicit

Constructor.

Parameters
nameFully qualified name for the message type as a FixedString.

◆ MessageType() [4/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( MetadataGeneratedName  name)
inlineexplicit

Constructor.

Parameters
nameFully qualified name for the message type as a MetadataGeneratedName.

◆ MessageType() [5/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( FixedString  name,
PropertyTypeEditorInfoSharedPtr  editorInfo 
)
inlineexplicit

Constructor.

Parameters
nameFully qualified name for the message type as a FixedString.
editorInfoSets the editor information for this message type that Kanzi Studio uses.

◆ MessageType() [6/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( MetadataGeneratedName  name,
PropertyTypeEditorInfoSharedPtr  editorInfo 
)
inlineexplicit

Constructor.

Parameters
nameFully qualified name for the message type as a MetadataGeneratedName.
editorInfoSets the editor information for this message type that Kanzi Studio uses.

◆ ~MessageType()

template<class TArguments>
kanzi::MessageType< TArguments >::~MessageType ( )
inline

Destructor.

◆ MessageType() [7/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( const MessageType< TArguments > &  )
delete

Deleted copy constructor.

◆ MessageType() [8/8]

template<class TArguments>
kanzi::MessageType< TArguments >::MessageType ( )
explicitprotecteddefault

Constructor.

Used by DynamicMessageType.

Member Function Documentation

◆ operator AbstractMessageType()

template<class TArguments>
kanzi::MessageType< TArguments >::operator AbstractMessageType ( ) const
inline

Conversion operator to AbstractMessageType.

Returns
The message type as an AbstractMessageType.

◆ getName()

template<class TArguments>
string kanzi::MessageType< TArguments >::getName ( ) const
inline

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

Returns
The fully qualified name of the message type.

◆ getRouting()

template<class TArguments>
MessageRouting kanzi::MessageType< TArguments >::getRouting ( ) const
inline

Gets the message routing of the message type.

Returns
MessageRouting mode of the message type.

◆ getArgumentsMetaclass()

template<class TArguments>
static const Metaclass* kanzi::MessageType< TArguments >::getArgumentsMetaclass ( )
inlinestatic

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

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

◆ get()

template<class TArguments>
const AbstractMessageTypeDescriptor* kanzi::MessageType< TArguments >::get ( ) const
inline

Gets the AbstractMessageTypeDescriptor of the message type.

Returns
The AbstractMessageTypeDescriptor pointer of the MessageType.

◆ getEditorInfo()

template<class TArguments>
PropertyTypeEditorInfoSharedPtr kanzi::MessageType< TArguments >::getEditorInfo ( ) const
inline

Gets the editor information for the message type.

Returns
The editor information for the message type.

◆ hasCustomArgumentsClass()

template<class TArguments>
static constexpr bool kanzi::MessageType< TArguments >::hasCustomArgumentsClass ( )
inlinestatic

Returns whether the message arguments class associated with the message type is a custom message arguments class or the base MessageArguments class.

Returns
If the message arguments class is a custom class, true, otherwise false.

◆ operator=()

template<class TArguments>
MessageType& kanzi::MessageType< TArguments >::operator= ( const MessageType< TArguments > &  )
delete

Deleted assignment.

Friends And Related Function Documentation

◆ AbstractMessageType

template<class TArguments>
friend class AbstractMessageType
friend

◆ DynamicMessageType

template<class TArguments>
template<typename T >
friend class DynamicMessageType
friend

Member Data Documentation

◆ m_descriptor

template<class TArguments>
const AbstractMessageTypeDescriptor* kanzi::MessageType< TArguments >::m_descriptor
protected

Describes the name, routing, and message arguments metaclass of the message type.


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