SObjectizer-5 Extra
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container > Class Template Referencefinal

A template for broadcasting mbox with fixed set of destinations. More...

#include <broadcast.hpp>

Inheritance diagram for so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >:

Public Member Functions

mbox_id_t id () const override
 
void subscribe_event_handler (const std::type_index &, const message_limit::control_block_t *, agent_t &) override
 
void unsubscribe_event_handlers (const std::type_index &, agent_t &) override
 
std::string query_name () const override
 
mbox_type_t type () const override
 
void do_deliver_message (const std::type_index &msg_type, const message_ref_t &message, unsigned int overlimit_reaction_deep) override
 
void set_delivery_filter (const std::type_index &, const delivery_filter_t &, agent_t &) override
 
void drop_delivery_filter (const std::type_index &, agent_t &) noexcept override
 
environment_t & environment () const noexcept override
 

Static Public Member Functions

static mbox_t make (environment_t &env, const Container &destinations)
 Factory method for the creation of new instance of a mbox. More...
 
static mbox_t make (environment_t &env, Container &&destinations)
 Factory method for the creation of new instance of a mbox. More...
 
template<typename Input_It >
static mbox_t make (environment_t &env, Input_It first, Input_It last)
 Factory method for the creation of new instance of a mbox. More...
 
template<typename Another_Container >
static mbox_t make (environment_t &env, const Another_Container &destinations)
 Factory method for the creation of new instance of a mbox. More...
 

Protected Member Functions

 fixed_mbox_template_t (outliving_reference_t< environment_t > env, mbox_id_t id, const Container &destinations)
 Initializing constructor. More...
 
 fixed_mbox_template_t (outliving_reference_t< environment_t > env, mbox_id_t id, Container &&destinations)
 Initializing constructor. More...
 
template<typename Input_It >
 fixed_mbox_template_t (outliving_reference_t< environment_t > env, mbox_id_t id, Input_It first, Input_It last)
 Initializing constructor. More...
 

Private Attributes

outliving_reference_t< environment_t > m_env
 
const mbox_id_t m_id
 
const Container m_destinations
 

Detailed Description

template<typename Container = std::vector<mbox_t>>
class so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >

A template for broadcasting mbox with fixed set of destinations.

Note
A set of destination is fixed at the creation time and can't be changed later. It can be not flexible enough for some senarios, but allows to avoid any additional locks during the delivery of a message.
This type has no public constructors. To create an instance of that type public static make methods should be used.
Attention
This type of mbox prohibits the delivery of mutable messages. It is because this is MPMC mbox.
This type of mbox prohibits subscriptions and usage of delivery filters. An attempt to create a subscription or an attempt to set a delivery filter will lead to an exception.
Template Parameters
ContainerType of a container for holding list of destination mboxes. By default it is std::vector<mbox_t> but a user can set any type of sequential container. For example:
Since
v.1.3.1

Definition at line 60 of file broadcast.hpp.

Constructor & Destructor Documentation

◆ fixed_mbox_template_t() [1/3]

template<typename Container = std::vector<mbox_t>>
so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::fixed_mbox_template_t ( outliving_reference_t< environment_t >  env,
mbox_id_t  id,
const Container &  destinations 
)
inlineprotected

Initializing constructor.

Intended for the case when a set of destinations should be taken from a const reference to the container of the same type.

Parameters
envSObjectizer Environment to work in.
idA unique ID of that
destinationsSource container with a set of destination mboxes.

Definition at line 72 of file broadcast.hpp.

◆ fixed_mbox_template_t() [2/3]

template<typename Container = std::vector<mbox_t>>
so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::fixed_mbox_template_t ( outliving_reference_t< environment_t >  env,
mbox_id_t  id,
Container &&  destinations 
)
inlineprotected

Initializing constructor.

Intended for the case when a set of destinations should be borrowed (moved) from a temporary container of the same type.

Parameters
envSObjectizer Environment to work in.
idA unique ID of that
destinationsSource container with a set of destination mboxes. The content of this container will be borrowed.

Definition at line 89 of file broadcast.hpp.

◆ fixed_mbox_template_t() [3/3]

template<typename Container = std::vector<mbox_t>>
template<typename Input_It >
so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::fixed_mbox_template_t ( outliving_reference_t< environment_t >  env,
mbox_id_t  id,
Input_It  first,
Input_It  last 
)
inlineprotected

Initializing constructor.

Intended for the case when a set of destination mboxes is specified by a pair of iterators.

Parameters
envSObjectizer Environment to work in.
idA unique ID of that
firstThe left border of a range (inclusive).
lastThe right border of a range (exclusive).

Definition at line 108 of file broadcast.hpp.

Member Function Documentation

◆ do_deliver_message()

template<typename Container = std::vector<mbox_t>>
void so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::do_deliver_message ( const std::type_index &  msg_type,
const message_ref_t &  message,
unsigned int  overlimit_reaction_deep 
)
inlineoverride

Definition at line 161 of file broadcast.hpp.

◆ drop_delivery_filter()

template<typename Container = std::vector<mbox_t>>
void so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::drop_delivery_filter ( const std::type_index &  ,
agent_t &   
)
inlineoverridenoexcept

Definition at line 186 of file broadcast.hpp.

◆ environment()

template<typename Container = std::vector<mbox_t>>
environment_t& so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::environment ( ) const
inlineoverridenoexcept

Definition at line 192 of file broadcast.hpp.

◆ id()

template<typename Container = std::vector<mbox_t>>
mbox_id_t so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::id ( ) const
inlineoverride

Definition at line 124 of file broadcast.hpp.

◆ make() [1/4]

template<typename Container = std::vector<mbox_t>>
static mbox_t so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::make ( environment_t &  env,
const Container &  destinations 
)
inlinestatic

Factory method for the creation of new instance of a mbox.

Copies the whole content from destinations container.

Usage example:

std::vector< so_5::mbox_t > destinations;
destinations.push_back( some_agent->so_direct_mbox() );
destinations.push_back( another_agent->so_direct_mbox() );
...
auto first_broadcaster = broadcasting_mbox::make( env, destinations );
auto second_broadcaster = broadcasting_mbox::make( env, destinations );
...
Parameters
envSObjectizer Environment to work in.
destinationsA set of destinations for a new mbox.
Examples:
mboxes/broadcast/simple/main.cpp.

Definition at line 216 of file broadcast.hpp.

◆ make() [2/4]

template<typename Container = std::vector<mbox_t>>
static mbox_t so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::make ( environment_t &  env,
Container &&  destinations 
)
inlinestatic

Factory method for the creation of new instance of a mbox.

Borrows (moves from) the whole content from destinations container.

Usage example:

std::vector< so_5::mbox_t > make_destinations() {
std::vector< so_5::mbox_t > result;
result.push_back( some_agent->so_direct_mbox() );
result.push_back( another_agent->so_direct_mbox() );
...
return result;
}
auto broadcaster = broadcasting_mbox::make( env, make_destinations() );
...
Parameters
envSObjectizer Environment to work in.
destinationsA temporary container with a set of destination mboxes. The content of that container will be moved into a new mbox.

Definition at line 255 of file broadcast.hpp.

◆ make() [3/4]

template<typename Container = std::vector<mbox_t>>
template<typename Input_It >
static mbox_t so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::make ( environment_t &  env,
Input_It  first,
Input_It  last 
)
inlinestatic

Factory method for the creation of new instance of a mbox.

Uses values from a range [first, last) for initialization of destinations container.

Usage example:

so_5::mbox_t destinations[] = {
some_agent->so_direct_mbox(),
another_agent->so_direct_mbox(),
...
};
auto broadcaster = broadcasting_mbox::make( env,
std::begin(destinations), std::end(destinations) );
...
Parameters
envSObjectizer Environment to work in.
firstThe left border of a range (inclusive).
lastThe right border of a range (exclusive).

Definition at line 296 of file broadcast.hpp.

◆ make() [4/4]

template<typename Container = std::vector<mbox_t>>
template<typename Another_Container >
static mbox_t so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::make ( environment_t &  env,
const Another_Container &  destinations 
)
inlinestatic

Factory method for the creation of new instance of a mbox.

Uses the whole content of a container of other type.

Usage example:

std::array<so_5::mbox_t, 5> destinations{
some_agent->so_direct_mbox(),
another_agent->so_direct_mbox(),
...
};
auto broadcaster = broadcasting_mbox::make( env, destinations );
...
Parameters
envSObjectizer Environment to work in.
destinationsThe container (or range object) with a set of destinations to a new mbox.

Definition at line 336 of file broadcast.hpp.

◆ query_name()

template<typename Container = std::vector<mbox_t>>
std::string so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::query_name ( ) const
inlineoverride

Definition at line 146 of file broadcast.hpp.

◆ set_delivery_filter()

template<typename Container = std::vector<mbox_t>>
void so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::set_delivery_filter ( const std::type_index &  ,
const delivery_filter_t &  ,
agent_t &   
)
inlineoverride

Definition at line 176 of file broadcast.hpp.

◆ subscribe_event_handler()

template<typename Container = std::vector<mbox_t>>
void so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::subscribe_event_handler ( const std::type_index &  ,
const message_limit::control_block_t *  ,
agent_t &   
)
inlineoverride

Definition at line 127 of file broadcast.hpp.

◆ type()

template<typename Container = std::vector<mbox_t>>
mbox_type_t so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::type ( ) const
inlineoverride

Definition at line 155 of file broadcast.hpp.

◆ unsubscribe_event_handlers()

template<typename Container = std::vector<mbox_t>>
void so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::unsubscribe_event_handlers ( const std::type_index &  ,
agent_t &   
)
inlineoverride

Definition at line 137 of file broadcast.hpp.

Member Data Documentation

◆ m_destinations

template<typename Container = std::vector<mbox_t>>
const Container so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::m_destinations
private

Definition at line 64 of file broadcast.hpp.

◆ m_env

template<typename Container = std::vector<mbox_t>>
outliving_reference_t< environment_t > so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::m_env
private

Definition at line 62 of file broadcast.hpp.

◆ m_id

template<typename Container = std::vector<mbox_t>>
const mbox_id_t so_5::extra::mboxes::broadcast::fixed_mbox_template_t< Container >::m_id
private

Definition at line 63 of file broadcast.hpp.


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