Qpid Proton C++  0.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
default_container Class Reference

A single-threaded container. More...

#include <default_container.hpp>

Inheritance diagram for default_container:
container

Public Member Functions

 default_container (proton::messaging_handler &h, const std::string &id="")
 Create a default, single-threaded container with a messaging_handler. More...
 
 default_container (const std::string &id="")
 Create a default, single-threaded container without a messaging_handler. More...
 
 default_container (container *c)
 Wrap an existing container implementation as a default_container. More...
 
returned< connectionconnect (const std::string &url, const connection_options &)
 Connect to url and send an open request to the remote peer. More...
 
listener listen (const std::string &url, listen_handler &l)
 Start listening on url. More...
 
void run ()
 Run the container in this thread. More...
 
void auto_stop (bool set)
 If true, stop the container when all active connections and listeners are closed. More...
 
void stop (const error_condition &err=error_condition())
 Experimental - Stop the container with an optional error_condition err. More...
 
returned< senderopen_sender (const std::string &url, const proton::sender_options &o=proton::sender_options(), const connection_options &c=connection_options())
 Open a connection and sender for url. More...
 
returned< receiveropen_receiver (const std::string &url, const proton::receiver_options &o=proton::receiver_options(), const connection_options &c=connection_options())
 Open a connection and receiver for url. More...
 
std::string id () const
 A unique identifier for the container.
 
void client_connection_options (const connection_options &o)
 Connection options that will be to outgoing connections. More...
 
connection_options client_connection_options () const
 Connection options that will be to outgoing connections. More...
 
void server_connection_options (const connection_options &o)
 Connection options that will be applied to incoming connections. More...
 
connection_options server_connection_options () const
 Connection options that will be applied to incoming connections. More...
 
void sender_options (const class sender_options &o)
 Sender options applied to senders created by this container. More...
 
class sender_options sender_options () const
 Sender options applied to senders created by this container. More...
 
void receiver_options (const class receiver_options &o)
 Receiver options applied to receivers created by this container. More...
 
class receiver_options receiver_options () const
 Receiver options applied to receivers created by this container. More...
 
returned< connectionconnect (const std::string &url)
 Connect to url and send an open request to the remote peer.
 
virtual listener listen (const std::string &url, const connection_options &)
 Listen with a fixed set of options for all accepted connections. More...
 
virtual listener listen (const std::string &url)
 Start listening on URL. More...
 
virtual returned< senderopen_sender (const std::string &url)
 Open a connection and sender for url.
 
virtual returned< senderopen_sender (const std::string &url, const proton::sender_options &o)
 Open a connection and sender for url. More...
 
virtual returned< receiveropen_receiver (const std::string &url)
 Open a connection and receiver for url.
 
virtual returned< receiveropen_receiver (const std::string &url, const proton::receiver_options &o)
 Open a connection and receiver for url. More...
 

Detailed Description

A single-threaded container.

A top-level container of connections, sessions, senders, and receivers. A container gives a unique identity to each communicating peer. It is often a process-level object.

It serves as an entry point to the API, allowing connections, senders, and receivers to be established. It can be supplied with an event handler in order to intercept important messaging events, such as newly received messages or newly issued credit for sending messages.

Examples:
broker.cpp, client.cpp, direct_recv.cpp, direct_send.cpp, helloworld.cpp, helloworld_direct.cpp, server.cpp, server_direct.cpp, simple_recv.cpp, and simple_send.cpp.

Constructor & Destructor Documentation

default_container ( proton::messaging_handler h,
const std::string &  id = "" 
)
explicit

Create a default, single-threaded container with a messaging_handler.

The messaging_handler will be called for all events on all connections in the container.

Container ID should be unique within your system. If empty a random UUID is generated.

default_container ( const std::string &  id = "")
explicit

Create a default, single-threaded container without a messaging_handler.

Connections get their handlesr via proton::connection_options. Container-wide defaults are set with client_connection_options() and server_connection_options(). Per-connection options are set in connect() and proton_listen_handler::on_accept for the proton::listen_handler passed to listen()

Container ID should be unique within your system. If empty a random UUID is generated.

default_container ( container c)
inlineexplicit

Wrap an existing container implementation as a default_container.

Takes ownership of c.

Member Function Documentation

void auto_stop ( bool  )
virtual

If true, stop the container when all active connections and listeners are closed.

If false the container will keep running till stop() is called.

auto_stop is set by default when a new container is created.

Implements container.

void client_connection_options ( const connection_options )
virtual

Connection options that will be to outgoing connections.

These are applied first and overriden by options provided in connect() and messaging_handler::on_connection_open().

Implements container.

connection_options client_connection_options ( ) const
virtual

Connection options that will be to outgoing connections.

These are applied first and overriden by options provided in connect() and messaging_handler::on_connection_open().

Implements container.

returned<connection> connect ( const std::string &  url,
const connection_options  
)
virtual

Connect to url and send an open request to the remote peer.

Options are applied to the connection as follows, values in later options override earlier ones:

  1. client_connection_options()
  2. options passed to connect()

The handler in the composed options is used to call proton::messaging_handler::on_connection_open() when the remote peer's open response is received.

Implements container.

listener listen ( const std::string &  url,
listen_handler lh 
)
virtual

Start listening on url.

Calls to the listen_handler are serialized for this listener, but handlers attached to separate listeners may be called concurrently.

Parameters
urlidentifies a listening url.
lhhandles listening events
Returns
listener lets you stop listening

Implements container.

virtual listener listen ( const std::string &  url,
const connection_options  
)
virtualinherited

Listen with a fixed set of options for all accepted connections.

See listen(const std::string&, listen_handler&)

virtual listener listen ( const std::string &  url)
virtualinherited

Start listening on URL.

New connections will use the handler from server_connection_options()

returned<receiver> open_receiver ( const std::string &  url,
const proton::receiver_options o = proton::receiver_options(),
const connection_options c = connection_options() 
)
virtual

Open a connection and receiver for url.

Any supplied receiver or connection options will override the container's template options.

Implements container.

virtual returned<receiver> open_receiver ( const std::string &  url,
const proton::receiver_options o 
)
virtualinherited

Open a connection and receiver for url.

Any supplied receiver options will override the container's template options.

returned<sender> open_sender ( const std::string &  url,
const proton::sender_options o = proton::sender_options(),
const connection_options c = connection_options() 
)
virtual

Open a connection and sender for url.

Any supplied sender or connection options will override the container's template options.

Implements container.

virtual returned<sender> open_sender ( const std::string &  url,
const proton::sender_options o 
)
virtualinherited

Open a connection and sender for url.

Any supplied sender options will override the container's template options.

class receiver_options receiver_options ( ) const
virtual

Receiver options applied to receivers created by this container.

They are applied before messaging_handler::on_receiver_open() and can be overridden.

Implements container.

void receiver_options ( const class receiver_options )
virtual

Receiver options applied to receivers created by this container.

They are applied before messaging_handler::on_receiver_open() and can be overridden.

Implements container.

void run ( )
virtual

Run the container in this thread.

Returns when the container stops.

See Also
auto_stop() and stop().

With a multithreaded container, call run() in multiple threads to create a thread pool.

Implements container.

Examples:
client.cpp, direct_recv.cpp, direct_send.cpp, helloworld.cpp, helloworld_direct.cpp, server.cpp, server_direct.cpp, simple_recv.cpp, and simple_send.cpp.
class sender_options sender_options ( ) const
virtual

Sender options applied to senders created by this container.

They are applied before messaging_handler::on_sender_open() and can be overridden.

Implements container.

void sender_options ( const class sender_options )
virtual

Sender options applied to senders created by this container.

They are applied before messaging_handler::on_sender_open() and can be overridden.

Implements container.

void server_connection_options ( const connection_options )
virtual

Connection options that will be applied to incoming connections.

These are applied first and overridden by options provided in listen(), listen_handler::on_accept() and messaging_handler::on_connection_open().

Implements container.

connection_options server_connection_options ( ) const
virtual

Connection options that will be applied to incoming connections.

These are applied first and overridden by options provided in listen(), listen_handler::on_accept() and messaging_handler::on_connection_open().

Implements container.

void stop ( const error_condition err = error_condition())
virtual

Experimental - Stop the container with an optional error_condition err.

  • Abort all open connections and listeners.
  • Process final handler events and injected functions
  • If !err.empty(), handlers will receive on_transport_error
  • run() will return in all threads.

Implements container.


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