Serial-TCP/IPbridge
1.0
|
Configuration for a TCP/IP server. More...
#include <tcpip_config.h>
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... | |
TCPIPConfig & | operator= (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... | |
Config & | operator= (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... | |
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).
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.
TCPIPConfig::~TCPIPConfig | ( | ) |
Destructor.
Destroys a TCPIPConfig object.
TCPIPConfig::TCPIPConfig | ( | const TCPIPConfig & | other | ) |
Copy constructor.
other | Object that will be used as a model in the object creation. |
Constructs a copy of the other object.
|
private |
Default constructor.
Constructs an empty TCPIPConfig object.
|
private |
Constructor.
rawConfigValues | Raw configuration option -> values mappings. |
Constructs a TCPIPConfig object from the selected values.
|
static |
Creates a TCPIPConfig object from raw configuration values.
rawConfigValues | Raw configuration option -> values mappings. |
If some passed value is invalid, InvalidValueError will be thrown.
Preconditions:
Meets the strong guarantee of exception safety.
|
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.
|
inline |
Returns the port number on which the TCP/IP server should listen.
References _port.
|
inline |
Returns the connection timout (in seconds).
References _timeout.
bool TCPIPConfig::operator!= | ( | const TCPIPConfig & | other | ) | const |
Non-equality comparison.
other | Object that will be compared with this object. |
TCPIPConfig& TCPIPConfig::operator= | ( | const TCPIPConfig & | other | ) |
Assignment operator.
other | Object that will be assigned to this object. |
Guarantees the strong exception safety.
bool TCPIPConfig::operator== | ( | const TCPIPConfig & | other | ) | const |
Equality comparison.
other | Object that will be compared with this object. |
|
staticprivate |
|
staticprivate |
|
staticprivate |
void TCPIPConfig::swap | ( | TCPIPConfig & | other | ) |
Swap the contents of this object with the other object.
other | Object that will be swapped with this object. |
Guarantees nothrow exception safety.
|
private |
Interfaces on which the TCP/IP server should listen.
Referenced by getInterfaces().
|
private |
Port number on which the TCP/IP server should listen.
Referenced by getPort().
|
private |
Connection timeout (in seconds).
Referenced by getTimeout().
|
static |
This value that can be returned in an Interfaces container and it means that the server should listen on every interface.
|
staticprivate |
Default port number.
|
staticprivate |
Default connection timeout (in seconds).