Serial-TCP/IPbridge  1.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TCPIPConfig Class Reference

Configuration for a TCP/IP server. More...

#include <tcpip_config.h>

Inheritance diagram for TCPIPConfig:
Config

Public Types

typedef std::vector< std::string > Interfaces
 List of network iterfaces. More...
 
typedef std::tr1::uint16_t Port
 Port number type. More...
 
typedef time_t Timeout
 Timeout type. More...
 
- Public Types inherited from Config
typedef std::map< std::string,
std::string > 
RawConfigValues
 Raw configuration option -> values mapping. More...
 
typedef size_t BufferSize
 Buffer size type. More...
 
typedef unsigned LengthField
 Length field type. More...
 
typedef std::tr1::uint32_t LengthFieldMessageLength
 Message length type when using length field. More...
 

Public Member Functions

 ~TCPIPConfig ()
 Destructor. More...
 
 TCPIPConfig (const TCPIPConfig &other)
 Copy constructor. More...
 
TCPIPConfigoperator= (const TCPIPConfig &other)
 Assignment operator. More...
 
bool operator== (const TCPIPConfig &other) const
 Equality comparison. More...
 
bool operator!= (const TCPIPConfig &other) const
 Non-equality comparison. More...
 
void swap (TCPIPConfig &other)
 Swap the contents of this object with the other object. More...
 
Interfaces getInterfaces () const
 Returns the list of interfaces on which the TCP/IP server should listen. More...
 
Port getPort () const
 Returns the port number on which the TCP/IP server should listen. More...
 
time_t getTimeout () const
 Returns the connection timout (in seconds). More...
 
- Public Member Functions inherited from Config
 ~Config ()
 Destructor. More...
 
 Config (const Config &other)
 Copy constructor. More...
 
Configoperator= (const Config &other)
 Assignment operator. More...
 
bool operator== (const Config &other) const
 Equality comparison. More...
 
bool operator!= (const Config &other) const
 Non-equality comparison. More...
 
void swap (Config &other)
 Swap the contents of this object with the other object. More...
 
size_t getBufferSize () const
 Returns the buffer size (in bytes). More...
 
LengthField getLengthField () const
 Returns the size of a field containing the length of a message (in bytes). More...
 

Static Public Member Functions

static TCPIPConfig fromRawConfigValues (RawConfigValues rawConfigValues)
 Creates a TCPIPConfig object from raw configuration values. More...
 
- Static Public Member Functions inherited from Config
static Config fromRawConfigValues (RawConfigValues rawConfigValues)
 Creates a Config object from raw configuration values. More...
 
static LengthFieldMessageLength binaryFieldLengthToNumber (const std::string &binaryNumber)
 Transforms the selected binary string into a number. More...
 
static LengthFieldMessageLength computeMaximalMessageLength (unsigned lengthField)
 Returns the maximal message size that can be stored in lengthField bytes. More...
 
static std::string messageLengthToBinaryLengthField (LengthFieldMessageLength messageLength, unsigned lengthField)
 Transforms the selected message length into a binary length field string. More...
 

Static Public Attributes

static const std::string ANY_INTERFACE
 

Private Member Functions

 TCPIPConfig ()
 Default constructor. More...
 
 TCPIPConfig (Config::RawConfigValues rawConfigValues)
 Constructor. More...
 

Static Private Member Functions

static Interfaces parseInterfaces (const std::string &rawInterfaces)
 
static Port parsePort (const std::string &rawPort)
 
static Timeout parseTimeout (const std::string &rawTimeout)
 

Private Attributes

Interfaces _interfaces
 Interfaces on which the TCP/IP server should listen. More...
 
Port _port
 Port number on which the TCP/IP server should listen. More...
 
Timeout _timeout
 Connection timeout (in seconds). More...
 

Static Private Attributes

static const Port DEFAULT_PORT
 Default port number. More...
 
static const Timeout DEFAULT_TIMEOUT
 Default connection timeout (in seconds). More...
 

Additional Inherited Members

- Protected Member Functions inherited from Config
 Config ()
 Default constructor. More...
 
 Config (RawConfigValues rawConfigValues)
 Constructor. More...
 
- Static Protected Member Functions inherited from Config
template<typename T >
static T parseNumber (const std::string &optionName, const std::string &rawValue, T minValue, T maxValue)
 Parses the selected number from the selected string. More...
 

Detailed Description

Configuration for a TCP/IP server.

This class provides a transformation of raw config values into verified and typed configuration values for a TCP/IP server and connections.

It provides value semantics (object copying and comparison is allowed).

Member Typedef Documentation

typedef std::vector<std::string> TCPIPConfig::Interfaces

List of network iterfaces.

typedef std::tr1::uint16_t TCPIPConfig::Port

Port number type.

typedef time_t TCPIPConfig::Timeout

Timeout type.

Constructor & Destructor Documentation

TCPIPConfig::~TCPIPConfig ( )

Destructor.

Destroys a TCPIPConfig object.

TCPIPConfig::TCPIPConfig ( const TCPIPConfig other)

Copy constructor.

Parameters
otherObject that will be used as a model in the object creation.

Constructs a copy of the other object.

TCPIPConfig::TCPIPConfig ( )
private

Default constructor.

Constructs an empty TCPIPConfig object.

TCPIPConfig::TCPIPConfig ( Config::RawConfigValues  rawConfigValues)
private

Constructor.

Parameters
rawConfigValuesRaw configuration option -> values mappings.

Constructs a TCPIPConfig object from the selected values.

Member Function Documentation

static TCPIPConfig TCPIPConfig::fromRawConfigValues ( RawConfigValues  rawConfigValues)
static

Creates a TCPIPConfig object from raw configuration values.

Parameters
rawConfigValuesRaw configuration option -> values mappings.

If some passed value is invalid, InvalidValueError will be thrown.

Preconditions:

  • each option name and value must be without beginning and trailing white spaces

Meets the strong guarantee of exception safety.

Interfaces TCPIPConfig::getInterfaces ( ) const
inline

Returns the list of interfaces on which the TCP/IP server should listen.

If the resulting list contains only one interface named "ANY", then it means that the server should listen on all available interfaces. Iterface could be either a network iterface (like "eth0") or an IPv4 address (like 212.45.97.22).

References _interfaces.

Port TCPIPConfig::getPort ( ) const
inline

Returns the port number on which the TCP/IP server should listen.

References _port.

time_t TCPIPConfig::getTimeout ( ) const
inline

Returns the connection timout (in seconds).

References _timeout.

bool TCPIPConfig::operator!= ( const TCPIPConfig other) const

Non-equality comparison.

Parameters
otherObject that will be compared with this object.
Returns
True if this object is not equal to the other object.
TCPIPConfig& TCPIPConfig::operator= ( const TCPIPConfig other)

Assignment operator.

Parameters
otherObject that will be assigned to this object.
Returns
Reference to this object.

Guarantees the strong exception safety.

bool TCPIPConfig::operator== ( const TCPIPConfig other) const

Equality comparison.

Parameters
otherObject that will be compared with this object.
Returns
True if this object is equal to the other object.
static Interfaces TCPIPConfig::parseInterfaces ( const std::string &  rawInterfaces)
staticprivate
static Port TCPIPConfig::parsePort ( const std::string &  rawPort)
staticprivate
static Timeout TCPIPConfig::parseTimeout ( const std::string &  rawTimeout)
staticprivate
void TCPIPConfig::swap ( TCPIPConfig other)

Swap the contents of this object with the other object.

Parameters
otherObject that will be swapped with this object.

Guarantees nothrow exception safety.

Member Data Documentation

Interfaces TCPIPConfig::_interfaces
private

Interfaces on which the TCP/IP server should listen.

Referenced by getInterfaces().

Port TCPIPConfig::_port
private

Port number on which the TCP/IP server should listen.

Referenced by getPort().

Timeout TCPIPConfig::_timeout
private

Connection timeout (in seconds).

Referenced by getTimeout().

const std::string TCPIPConfig::ANY_INTERFACE
static

This value that can be returned in an Interfaces container and it means that the server should listen on every interface.

const Port TCPIPConfig::DEFAULT_PORT
staticprivate

Default port number.

const Timeout TCPIPConfig::DEFAULT_TIMEOUT
staticprivate

Default connection timeout (in seconds).


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