senf::SocketHandle< SPolicy > Class Template Reference
[The Handle Hierarchy]

basic SocketHandle supporting protocol and policy abstraction More...

#include <senf/Socket/SocketHandle.hh>

Inheritance diagram for senf::SocketHandle< SPolicy >:
Inheritance graph
[legend]

List of all members.


Detailed Description

template<class SPolicy>
class senf::SocketHandle< SPolicy >

basic SocketHandle supporting protocol and policy abstraction

The senfSocketHandle class introduces the two abstraction layers of the socket library. senf::SocketHandle does not provide socket functions it only provides the infrastructure necessary to support both, the protocol and the policy interface.

SocketHandle takes the socket policy as a template argument. SocketHandle also introduces the protocol class. However, the class has no public constructors (see the derived classes senf::ProtocolClientSocketHandle and senf::ProtocolServerSocketHandle).

The most important functionality provided by SocketHandle is the conversion constructor. This allows to implicitly convert between compatible socket handle types as specified by the socket policy. The conversion constructor is defined in such a way, that only valid conversions are possible (see the implementation source for a more complete discussion).

Template Parameters:
SPolicy  socket policy
Note:
This class is not meant to be used as a base-class outside the library implementation; The protected interface is for internal use only.
Todo:
Create a SocketHandleBase class and move some non-Policy dependent code there

Definition at line 69 of file SocketHandle.hh.


Classes

struct   IsCompatible
  Check policy compatibility. More...

Public Types

typedef SPolicy  Policy

Public Member Functions

template<class OtherPolicy >
IsCompatible< OtherPolicy >
::type const & 
operator= (SocketHandle< OtherPolicy > other)
  Assign from other socket handle checking policy < compatibility.
void  state (SocketStateMap &map, unsigned lod=0)
  Inquire state information of socket handle.
std::string  dumpState (unsigned lod=0)
  Format complete state information as string.
template<class Facet >
Facet &  facet ()
  Access a protocol facet.

Static Public Member Functions

static SocketHandle  cast_static (FileHandle handle)
static SocketHandle  cast_dynamic (FileHandle handle)

Related Functions

(Note that these are not member functions.)

template<class SPolicy >
std::ostream &  operator<< (std::ostream &os, SocketHandle< SPolicy > handle)
  Write stream status dump to output stream.
template<class Target , class Source >
Target  static_socket_cast (Source handle)
  static socket (down-)cast
template<class Target , class Source >
Target  dynamic_socket_cast (Source handle)
  dynamic socket (down-)cast
template<class Target , class Source >
bool  check_socket_cast (Source handle)
  dynamically check cast validity

Structors and default members

  SocketHandle ()
template<class OtherPolicy >
  SocketHandle (SocketHandle< OtherPolicy > other, typename IsCompatible< OtherPolicy >::type *=0)
  Convert from other socket handle checking policy < compatibility.

Protected Member Functions

  SocketHandle (std::auto_ptr< SocketBody > body)
  Initialize SocketHandle providing the protocol.
  SocketHandle (FileHandle other, bool isChecked)
  Initialize SocketHandle from arbitrary checked < FileHandle.
SocketBody body ()
  Access socket body.
SocketBody const &  body () const
  Access socket body in const context.
SocketProtocol protocol () const
  Access protocol class.
void  assign (FileHandle other)

Member Typedef Documentation

template<class SPolicy>
typedef SPolicy senf::SocketHandle< SPolicy >::
Policy

Definition at line 76 of file SocketHandle.hh.


Constructor & Destructor Documentation

template<class SPolicy >
senf::SocketHandle< SPolicy >::
SocketHandle ()

Definition at line 41 of file SocketHandle.cti.

template<class SPolicy >
template<class OtherPolicy >
senf::SocketHandle< SPolicy >::
SocketHandle ( SocketHandle< OtherPolicy >  other,
typename IsCompatible< OtherPolicy >::type = 0 )

Convert from other socket handle checking policy < compatibility.

Definition at line 46 of file SocketHandle.cti.

template<class SPolicy >
senf::SocketHandle< SPolicy >::
SocketHandle ( std::auto_ptr< SocketBody body )

Initialize SocketHandle providing the protocol.

Parameters:
protocol  Protocol class of the protocol implemented by this socket handle
isServer  true, if this SobcketHandle instance implements a server handle, false otherwise

Definition at line 62 of file SocketHandle.cti.

template<class SPolicy >
senf::SocketHandle< SPolicy >::
SocketHandle ( FileHandle  other,
bool  isChecked )

Initialize SocketHandle from arbitrary checked < FileHandle.

This constructor is used to support up- and downcasting of SocketHandle instances.

Warning:
It is absolutely necessary to ensure, that the FileHandle passed in is really a SocketHandle holding a SocketBody (and not a simple FileBody) instance. Additionally. the SocketPolicy absolutely must be compatible.
Parameters:
other  FileHandle to assign
isChecked  has to be true
Todo:
Answer, why the heck I need the isChecked parameter ??

Definition at line 67 of file SocketHandle.cti.


Member Function Documentation

template<class SPolicy >
void senf::SocketHandle< SPolicy >::
assign ( FileHandle  other )

For internal use only.

Definition at line 100 of file SocketHandle.cti.

template<class SPolicy >
senf::SocketBody const & senf::SocketHandle< SPolicy >::
body ()

Access socket body in const context.

This member replaces the corresponding FileHandle member and returns an appropriately cast body reference

Reimplemented from senf::FileHandle.

Definition at line 84 of file SocketHandle.cti.

template<class SPolicy >
senf::SocketBody & senf::SocketHandle< SPolicy >::
body ()

Access socket body.

This member replaces the corresponding FileHandle member and returns an appropriately cast body reference

Reimplemented from senf::FileHandle.

Definition at line 76 of file SocketHandle.cti.

template<class SPolicy >
std::string senf::SocketHandle< SPolicy >::
dumpState ( unsigned  lod = 0 )

Format complete state information as string.

Formats the complete state map value and returns it as a single multi-line string.

Parameters:
lod  level of detail requested. The interpretation of this value is protocol specific
Implementation note:
This member will be re-implemented in every derived class. See the state() documentation.

Reimplemented in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, and senf::ServerSocketHandle< SocketProtocol::Policy >.

Definition at line 190 of file SocketHandle.cti.

template<class SPolicy >
template<class Facet >
Facet & senf::SocketHandle< SPolicy >::
facet ()

Access a protocol facet.

This member will try to access the given protocol facet of the socket. If Facet is a valid facet of the protocol, it is returned, otherwise std::bad_cast will be thrown.

Exceptions:
std::bad_cast  if Facet is not a protocol facet of this socket
Returns:
the Facet protocol facet of this socket

Definition at line 199 of file SocketHandle.cti.

template<class SPolicy >
template<class OtherPolicy >
senf::SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type const & senf::SocketHandle< SPolicy >::
operator= ( SocketHandle< OtherPolicy >  other )

Assign from other socket handle checking policy < compatibility.

Definition at line 54 of file SocketHandle.cti.

template<class SPolicy >
senf::SocketProtocol & senf::SocketHandle< SPolicy >::
protocol ()

Access protocol class.

Definition at line 93 of file SocketHandle.cti.

template<class SPolicy >
void senf::SocketHandle< SPolicy >::
state ( SocketStateMap map,
unsigned  lod = 0 )

Inquire state information of socket handle.

The map argument (a string to string mapping) will be filled with information covering the current state of the socket. The information provided depends on the socket protocol. The amount of information returned can be controlled using the lod value.

See senf::SocketProtocol::state() for more information, how the Information is generated.

Parameters:
map  string to string mapping to be filled with state information
lod  level of detail requested. The interpretation of this value is protocol specific
Implementation note:
This member will be re-implemented in every derived class. This is very important since state() is not a virtual function (which we don't want since we don't want to add a vtable pointer to every handle instance).

Reimplemented in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, and senf::ServerSocketHandle< SocketProtocol::Policy >.

Definition at line 174 of file SocketHandle.cti.


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