Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | List of all members
mir::client::rpc::StreamTransport Class Referenceabstract

Responsible for shuttling bytes to and from the server. More...

#include <stream_transport.h>

Inheritance diagram for mir::client::rpc::StreamTransport:
[legend]

Classes

class  Observer
 Observer of IO status. More...
 

Public Member Functions

virtual ~StreamTransport ()=default
 
 StreamTransport ()=default
 
 StreamTransport (StreamTransport const &)=delete
 
StreamTransportoperator= (StreamTransport const &)=delete
 
virtual void register_observer (std::shared_ptr< Observer > const &observer)=0
 Register an IO observer. More...
 
virtual void receive_data (void *buffer, size_t bytes_requested)=0
 Read data from the server. More...
 
virtual void receive_data (void *buffer, size_t bytes_requested, std::vector< Fd > &fds)=0
 Read data and file descriptors from the server. More...
 
virtual void send_data (std::vector< uint8_t > const &buffer)=0
 Write data to the server. More...
 

Detailed Description

Responsible for shuttling bytes to and from the server.

This is a transport providing stream semantics. It does not preserve message boundaries, writes from the remote end are not guaranteed to become available for reading atomically, and local writes are not guaranteed to become available for reading at the remote end atomically.

In practice reads and writes of “small size” will be atomic. See your kernel source tree for a definition of “small size” :).

As it does not preserve message boundaries, partial reads do not discard any unread data waiting for reading. This applies for both binary data and file descriptors.

Note
It is safe to call a read and a write method simultaneously from different threads. Multiple threads calling the same function need synchronisation.

Constructor & Destructor Documentation

virtual mir::client::rpc::StreamTransport::~StreamTransport ( )
virtualdefault
Note
Upon completion of the destructor it is guaranteed that no methods will be called by the StreamTransport on any Observer that had been registered.
mir::client::rpc::StreamTransport::StreamTransport ( )
default
mir::client::rpc::StreamTransport::StreamTransport ( StreamTransport const &  )
delete

Member Function Documentation

StreamTransport& mir::client::rpc::StreamTransport::operator= ( StreamTransport const &  )
delete
virtual void mir::client::rpc::StreamTransport::receive_data ( void *  buffer,
size_t  bytes_requested 
)
pure virtual

Read data from the server.

Parameters
[out]bufferBuffer to read into
[in]bytes_requestedNumber of bytes to read
Exceptions
Astd::runtime_error if it is not possible to read read_bytes bytes from the server.
Note
This provides stream semantics - message boundaries are not preserved.

Implemented in mir::client::rpc::StreamSocketTransport.

virtual void mir::client::rpc::StreamTransport::receive_data ( void *  buffer,
size_t  bytes_requested,
std::vector< Fd > &  fds 
)
pure virtual

Read data and file descriptors from the server.

Parameters
[out]bufferBuffer to read into
[in]bytes_requestedNumber of bytes to read
[in,out]fdsFile descriptors received in this read. The value of fds.size() determines the number of file descriptors to receive.
Exceptions
Astd::runtime_error if it is not possible to read read_bytes bytes from the server or if it is not possible to read fds.size() file descriptors from the server.
Note
This provides stream semantics - message boundaries are not preserved.

Implemented in mir::client::rpc::StreamSocketTransport.

virtual void mir::client::rpc::StreamTransport::register_observer ( std::shared_ptr< Observer > const &  observer)
pure virtual

Register an IO observer.

Parameters
[in]observer
Note
There is no guarantee which thread will call into the observer. Synchronisation is the responsibility of the caller.
virtual void mir::client::rpc::StreamTransport::send_data ( std::vector< uint8_t > const &  buffer)
pure virtual

Write data to the server.

Parameters
[in]bufferData to send
Exceptions
Astd::runtime_error if it is not possible to write the full contents of buffer to the server.

Implemented in mir::client::rpc::StreamSocketTransport.


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

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014