Flow-IPC 3.0.0
Flow-IPC project: Public API.
Public Types | Public Member Functions | Static Public Attributes | Protected Types | Related Functions | List of all members
ipc::session::Server_session_mv< Server_session_impl_t > Class Template Reference

Implements Session concept on the Server_app end: a Session that is emitted in almost-PEER state by local Session_server accepting a connection by an opposing Client_session_mv::sync_connect(). More...

#include <server_session.hpp>

Inheritance diagram for ipc::session::Server_session_mv< Server_session_impl_t >:
[legend]
Collaboration diagram for ipc::session::Server_session_mv< Server_session_impl_t >:
[legend]

Public Types

using Base = Session_mv< Server_session_impl_t >
 Short-hand for our base class. To the user: note its public API is inherited.
 
using Async_io_obj = transport::Null_peer
 You may disregard.
 
using Sync_io_obj = sync_io::Server_session_adapter< Server_session_mv >
 Useful for generic programming, the sync_io-pattern counterpart to *this type.
 
- Public Types inherited from ipc::session::Session_mv< Server_session_impl_t >
using Channel_obj = typename Impl::Channel_obj
 Implements Session API per contract.
 
using Channels = typename Impl::Channels
 Container (vector<>) of Channel_obj.
 
using Mdt_payload_obj = typename Impl::Mdt_payload_obj
 Implements Session API per contract.
 
using Mdt_builder = typename Impl::Mdt_builder
 Implements Session API per contract.
 
using Mdt_builder_ptr = typename Impl::Mdt_builder_ptr
 Implements Session API per contract.
 
using Mdt_reader_ptr = typename Impl::Mdt_reader_ptr
 Implements Session API per contract.
 
using Structured_channel = typename transport::struc::Channel_via_heap< Channel_obj, Message_body >
 Implements Session API per contract. More...
 
using Structured_msg_builder_config = typename Impl::Structured_msg_builder_config
 Implements Session API per contract. More...
 
using Structured_msg_reader_config = typename Impl::Structured_msg_reader_config
 Implements Session API per contract. More...
 
using Info_collector = typename Impl::Info_collector
 Implements Session API per contract.
 

Public Member Functions

const Client_app * client_app () const
 The opposing application is described by a Client_app; this is that description. More...
 
template<typename Task_err , typename On_passive_open_channel_handler >
bool init_handlers (Task_err &&on_err_func_arg, On_passive_open_channel_handler &&on_passive_open_channel_func_arg)
 To be invoked by public user upon first obtaining *this: memorizes the given on-error and on-passive-open handlers thus moving this Server_session_mv to PEER state wherein it is a formal Session concept impl. More...
 
template<typename Task_err >
bool init_handlers (Task_err &&on_err_func_arg)
 Alternative to the other init_handlers(). More...
 
- Public Member Functions inherited from ipc::session::Session_mv< Server_session_impl_t >
 Session_mv ()
 Implements Session API per contract. More...
 
 Session_mv (Session_mv &&src)
 Implements Session API per contract. More...
 
 Session_mv (const Session_mv &)=delete
 Copy construction is disallowed.
 
 ~Session_mv ()
 Implements Session API per contract.
 
Session_mv & operator= (Session_mv &&src)
 Implements Session API per contract. More...
 
Session_mv & operator= (const Session_mv &)=delete
 Copy assignment is disallowed.
 
Mdt_builder_ptr mdt_builder ()
 Implements Session API per contract. More...
 
bool open_channel (Channel_obj *target_channel, const Mdt_builder_ptr &mdt, Error_code *err_code=nullptr)
 Implements Session API per contract. More...
 
bool open_channel (Channel_obj *target_channel, Error_code *err_code=nullptr)
 Implements Session API per contract. More...
 
const Session_token & session_token () const
 Implements Session API per contract. More...
 
const util::Process_credentials & remote_peer_process_credentials () const
 Implements Session API per contract. More...
 
Info_collector * info_collector ()
 Implements Session API per contract. More...
 
const Info_collector * info_collector () const
 Implements Session API per contract. More...
 
transport::struc::Heap_reader::Config heap_reader_config ()
 Non-static counterpart to other heap_reader_config() overload, equivalent to heap_reader_config(this->get_logger()). More...
 
flow::log::Logger * get_logger () const
 Returns logger (possibly null). More...
 
const flow::log::Component & get_log_component () const
 Returns log component. More...
 

Static Public Attributes

static constexpr bool S_IS_SRV_ELSE_CLI = true
 Implements Session API per contract: equals true.
 
- Static Public Attributes inherited from ipc::session::Session_mv< Server_session_impl_t >
static constexpr schema::ShmType S_SHM_TYPE_OR_NONE
 Implements Session API per contract.
 
static constexpr bool S_SHM_ENABLED
 Implements Session API per contract.
 
static constexpr bool S_MQS_ENABLED
 Compile-time-known constant indicating whether Channel_obj shall use a blobs pipe over message queues (MQs).
 
static constexpr bool S_SOCKET_STREAM_ENABLED
 Compile-time-known constant indicating whether Channel_obj shall use socket stream for any type of pipe. More...
 

Protected Types

using Session_base_obj = typename Base::Session_base_obj
 See Session_mv counterpart.
 
- Protected Types inherited from ipc::session::Session_mv< Server_session_impl_t >
using Impl = Server_session_impl_t
 Short-hand for pImpl-lite impl type. This shall be the deepest impl sub-class desired.
 
using Session_base_obj = typename Impl::Session_base_obj
 Short-hand for Impl's Session_base super-class.
 
using Impl_ptr = std::experimental::propagate_const< boost::movelib::unique_ptr< Impl > >
 Short-hand for const-respecting wrapper around Impl for the pImpl idiom. See impl().
 

Related Functions

(Note that these are not member functions.)

template<typename Server_session_impl_t >
std::ostream & operator<< (std::ostream &os, const Server_session_mv< Server_session_impl_t > &val)
 Prints string representation of the given Server_session_mv to the given ostream. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ipc::session::Session_mv< Server_session_impl_t >
static transport::struc::Heap_reader::Config heap_reader_config (flow::log::Logger *logger_ptr)
 Convenience Heap_reader::Config generator similar to struc::Channel::heap_reader_config(), but no Channel arg is necessary. More...
 
- Protected Member Functions inherited from ipc::session::Session_mv< Server_session_impl_t >
const Session_base_obj & base () const
 Provides const access to Session_base super-object. More...
 
Impl_ptr & impl ()
 pImpl target; particularly for sub-classes that must add to the above public API. More...
 
const Impl_ptr & impl () const
 pImpl target; particularly for sub-classes that must add to the above public API. More...
 

Detailed Description

template<typename Server_session_impl_t>
class ipc::session::Server_session_mv< Server_session_impl_t >

Implements Session concept on the Server_app end: a Session that is emitted in almost-PEER state by local Session_server accepting a connection by an opposing Client_session_mv::sync_connect().

By "almost-PEER state" we mean that the user, upon obtaining a new Server_session_mv, must still call init_handlers() to enter PEER state. See overview of Session hierarchy in namespace ipc::session doc header; then come back here if desired.

It is unusual to use Server_session_mv template directly. If you do wish to set up a server-side session peer, and you do not require SHM support, then use Server_session alias template; target it with a Session_server::async_accept() call. The server-specific API, particularly init_handlers(), is in Server_session_mv and documented here. The side-agnostic API – active once PEER state is achieved – is described by Session (concept) doc header and implemented concretely by Session_mv which is our public, non-virtual super-class.

If you do wish to set up a server-side session peer, but you do require SHM support, then use shm::classic::Server_session or similar (for other SHM-provider(s)); target it with a shm::classic::Session_server::async_accept() (or similar for other SHM-provider(s)). However Server_session (hence Server_session_mv to which it aliases) is its super-class, and until PEER state is reached its API (init_handlers()) remains the only relevant API to use. Once Server_session_mv::init_handlers() puts *this into PEER state, super-class Session_mv (= Session concept) API continues to be relevant. Also in PEER state SHM-relevant additional API members (e.g., shm::classic::Session_mv::app_shm()) become of interest. The last two sentences describe the situation identically for Client_session_mv as well (see its doc header for context).

Regarding when to destroy *this, relative to the objects around it (its channels et al; the Session_server that produced it): see Session_server doc header, section "How to use: Lifetime recommendations and requirements."

Summary hierarchy (contrast with similar spot in Client_session_mv doc header):

We may refer to Server_session_mv as Server_session below; particularly since it is likeliest used in that form by the user.

How to use

Per the Session concept a Server_session is open/capable of operation when in PEER state only. A publicly available Server_session object is always in one of 2 states:

Once in PEER state Server_session simply follows Session concept semantics. At this stage our super-class Session_mv implements that concept in particular. See either doc header (Session, Session_mv).

Error handling

Once in PEER state, error handling follows the Session concept (= Session_mv concrete class) doc header. However, up to that point it can emit no errors. You must call init_handlers() first to enter PEER state.

See also
Session: implemented concept.
Template Parameters
Server_session_impl_tAn implementation detail. Use one of the aliases prescribed near the top of this doc header to set this correctly.

Member Function Documentation

◆ client_app()

template<typename Server_session_impl_t >
const Client_app * ipc::session::Server_session_mv< Server_session_impl_t >::client_app

The opposing application is described by a Client_app; this is that description.

May be useful in particular when deciding what handlers to set up in init_handlers() when entering PEER state. Returns null if *this is as-if default-cted (i.e., default-cted + not moved-to otherwise; or moved-from).

Returns
Pointer to immutable Client_app; or null if *this is as-if default-cted. The pointer returned, when not straddling a move-to or move-from, is always the same.

◆ init_handlers() [1/2]

template<typename Server_session_impl_t >
template<typename Task_err >
bool ipc::session::Server_session_mv< Server_session_impl_t >::init_handlers ( Task_err &&  on_err_func_arg)

Alternative to the other init_handlers().

Using this overload indicates passive-opens are disabled on this side. Otherwise identical to the other init_handlers() overload.

Template Parameters
Task_errSee other init_handlers().
Parameters
on_err_func_argSee other init_handlers().
Returns
true normally; false if invoked after already having called an init_handlers() or as-if default-cted.

◆ init_handlers() [2/2]

template<typename Server_session_impl_t >
template<typename Task_err , typename On_passive_open_channel_handler >
bool ipc::session::Server_session_mv< Server_session_impl_t >::init_handlers ( Task_err &&  on_err_func_arg,
On_passive_open_channel_handler &&  on_passive_open_channel_func_arg 
)

To be invoked by public user upon first obtaining *this: memorizes the given on-error and on-passive-open handlers thus moving this Server_session_mv to PEER state wherein it is a formal Session concept impl.

Using this overload indicates passive-opens are enabled on this side.

Suggestion: use client_app() to determine the opposing Client_app, particularly if this Server_app is designed to accept sessions from 2+ Client_apps. (To be clear: Multiple instances (processes) of a given Client_app are always supported. However a given Server_app – specified at Session_server construction time – may well specify only one allowed opposing Client_app.) It is likely that a different on-passive-open handler would be useful depending on Client_app; possibly also different on-error handler.

Template Parameters
Task_errSee Session concept doc header for semantics.
On_passive_open_channel_handlerSee Session concept doc header for semantics.
Parameters
on_err_func_argOn-error handler per semantics in Session concept doc header.
on_passive_open_channel_func_argOn-passive-open handler per semantics in Session concept doc header.
Returns
true normally; false if invoked after already having called an init_handlers() or as-if default-cted.

Friends And Related Function Documentation

◆ operator<<()

template<typename Server_session_impl_t >
std::ostream & operator<< ( std::ostream &  os,
const Server_session_mv< Server_session_impl_t > &  val 
)
related

Prints string representation of the given Server_session_mv to the given ostream.

Parameters
osStream to which to write.
valObject to serialize.
Returns
os.

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