SObjectizer  5.5
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
so_5::message_t Class Reference

A base class for agent messages. More...

#include <message.hpp>

Inheritance diagram for so_5::message_t:
so_5::atomic_refcounted_t so_5::env_infrastructures::default_mt::impl::anonymous_namespace{mt_env_infrastructure.cpp}::msg_final_coop_dereg so_5::enveloped_msg::envelope_t so_5::msg_coop_deregistered so_5::msg_coop_registered so_5::signal_t so_5::stats::impl::st_env_stuff::next_turn_handler_t::next_turn so_5::stats::messages::distribution_finished so_5::stats::messages::distribution_started so_5::stats::messages::quantity< T > so_5::stats::messages::work_thread_activity so_5::user_type_message_t< T >

Public Types

using kind_t = ::so_5::message_kind_t
 A short typedef for kind of message. More...
 

Public Member Functions

 message_t ()
 
 message_t (const message_t &other)
 
 message_t (message_t &&other)
 
message_toperator= (const message_t &other)
 
message_toperator= (message_t &&other)
 
virtual ~message_t () noexcept=default
 
- Public Member Functions inherited from so_5::atomic_refcounted_t
 atomic_refcounted_t (const atomic_refcounted_t &)=delete
 
atomic_refcounted_toperator= (const atomic_refcounted_t &)=delete
 
 atomic_refcounted_t () noexcept
 Default constructor. More...
 
 ~atomic_refcounted_t () noexcept=default
 Destructor. More...
 
void inc_ref_count () noexcept
 Increments reference count. More...
 
unsigned long dec_ref_count () noexcept
 Decrement reference count. More...
 

Private Member Functions

virtual message_mutability_t so5_message_mutability () const noexcept
 Get message mutability flag. More...
 
virtual void so5_change_mutability (message_mutability_t mutability)
 Change message mutabilty flag. More...
 
virtual kind_t so5_message_kind () const noexcept
 Detect the kind of the message. More...
 

Private Attributes

message_mutability_t m_mutability
 Is message mutable or immutable? More...
 

Friends

class impl::internal_message_iface_t
 
message_mutability_t message_mutability (const intrusive_ptr_t< message_t > &what) noexcept
 Helper method for safe get of message mutability flag. More...
 
message_mutability_t message_mutability (const message_t &what) noexcept
 Helper method for get message mutability flag. More...
 
void change_message_mutability (intrusive_ptr_t< message_t > &what, message_mutability_t mutability)
 Helper method for safe change message mutability flag. More...
 
void change_message_mutability (message_t &what, message_mutability_t mutability)
 Helper method for change message mutability flag. More...
 
message_kind_t message_kind (const so_5::intrusive_ptr_t< message_t > &what)
 Helper method for quering kind of the message. More...
 
message_kind_t message_kind (const message_t &what)
 Helper method for quering kind of the message. More...
 

Detailed Description

A base class for agent messages.

All messages for agents must be derived from this class.

Attention
This class should be used for all messages which have an actual message data. For signals (messages without any data) a signal_t class should be used as a base class.
Note
Class message_t is derived from atomic_refcounted_t. But atomic_refcounted_t is not Copyable or Movable class. It means that copy/move constructors and operators for message_t have no influence on the reference counter inside message_t.
Examples:
so_5/chameneos_prealloc_msgs/main.cpp, so_5/modify_resend_as_immutable/main.cpp, so_5/mutable_msg_agents/main.cpp, so_5/news_board/main.cpp, so_5/prio_work_stealing/main.cpp, and so_5/simple_message_deadline/main.cpp.

Member Typedef Documentation

◆ kind_t

A short typedef for kind of message.

Since
v.5.5.23

Constructor & Destructor Documentation

◆ message_t() [1/3]

so_5::message_t::message_t ( )

◆ message_t() [2/3]

so_5::message_t::message_t ( const message_t other)

◆ message_t() [3/3]

so_5::message_t::message_t ( message_t &&  other)

◆ ~message_t()

virtual so_5::message_t::~message_t ( )
virtualdefaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

message_t & so_5::message_t::operator= ( const message_t other)

◆ operator=() [2/2]

message_t & so_5::message_t::operator= ( message_t &&  other)

◆ so5_change_mutability()

virtual void so_5::message_t::so5_change_mutability ( message_mutability_t  mutability)
inlineprivatevirtual

Change message mutabilty flag.

Attention
Changing mutability from message_mutability_t::immutable_message to message_mutability_t::mutable_message is a very bad idea. Please don't do this until you are know what you are doing.
Note
This method is intended to be used by SObjectizer and low-level SObjectizer extension. Because of that it is not guaranteed that this method is part of stable SObjectizer API. It can be changed or even removed in any future versions of SObjectizer.
This is a virual method because its behavious must be changed in msg_service_request_t.
Attention
This function can throw. For example a derived class can prohibit changing of message mutability.
Since
v.5.5.19
Parameters
mutabilityNew mutability flag for

◆ so5_message_kind()

virtual kind_t so_5::message_t::so5_message_kind ( ) const
inlineprivatevirtualnoexcept

Detect the kind of the message.

Note
This method is intended to be used by SObjectizer and low-level SObjectizer extension. Because of that it is not guaranteed that this method is part of stable SObjectizer API. It can be changed or even removed in any future versions of SObjectizer.
Since
v.5.5.23

Reimplemented in so_5::user_type_message_t< T >, so_5::signal_t, and so_5::enveloped_msg::envelope_t.

◆ so5_message_mutability()

virtual message_mutability_t so_5::message_t::so5_message_mutability ( ) const
inlineprivatevirtualnoexcept

Get message mutability flag.

Note
This method is intended to be used by SObjectizer and low-level SObjectizer extension. Because of that it is not guaranteed that this method is part of stable SObjectizer API. It can be changed or even removed in any future versions of SObjectizer.
This is a virual method because its behavious must be changed in msg_service_request_t.
Since
v.5.5.19

Friends And Related Function Documentation

◆ change_message_mutability [1/2]

void change_message_mutability ( intrusive_ptr_t< message_t > &  what,
message_mutability_t  mutability 
)
friend

Helper method for safe change message mutability flag.

Use this method instead of direct call to so5_change_mutability() because what will be nullptr for signals.

Note
This is a very dangerous operation. Don't do it by yourselt. See message_t::so5_change_mutability() for more details.
Attention
This function can throw. For example underlying message object can prohibit changing of message mutability.
Parameters
whatMessage instance to be modified if it is not a signal.
mutabilityNew mutability flag for the message.

◆ change_message_mutability [2/2]

void change_message_mutability ( message_t what,
message_mutability_t  mutability 
)
friend

Helper method for change message mutability flag.

Note
This is a very dangerous operation. Don't do it by yourselt. See message_t::so5_change_mutability() for more details.
Attention
This function can throw. For example underlying message object can prohibit changing of message mutability.
Parameters
whatMessage instance to be modified.
mutabilityNew mutability flag for the message.

◆ impl::internal_message_iface_t

friend class impl::internal_message_iface_t
friend

◆ message_kind [1/2]

message_kind_t message_kind ( const so_5::intrusive_ptr_t< message_t > &  what)
friend

Helper method for quering kind of the message.

This helper function is necessary because it correctly handles case when message is a signal. In that case pointer to message instance will be null.

Note
This function is part of internal implementation of SObjectizer. Don't use it directly. It can be a subject of changes in some future versions.
Since
v.5.5.23

◆ message_kind [2/2]

message_kind_t message_kind ( const message_t what)
friend

Helper method for quering kind of the message.

Note
This function is part of internal implementation of SObjectizer. Don't use it directly. It can be a subject of changes in some future versions.
Since
v.5.5.23

◆ message_mutability [1/2]

message_mutability_t message_mutability ( const intrusive_ptr_t< message_t > &  what)
friend

Helper method for safe get of message mutability flag.

Use this method instead of direct call to so5_message_mutability() because what will be nullptr for signals.

◆ message_mutability [2/2]

message_mutability_t message_mutability ( const message_t what)
friend

Helper method for get message mutability flag.

Member Data Documentation

◆ m_mutability

message_mutability_t so_5::message_t::m_mutability
private

Is message mutable or immutable?

By default the message is immutable.

Since
v.5.5.19

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