Serial-TCP/IPbridge
1.0
|
Configuration for a TCP/IP server. More...
#include <serial_config.h>
Public Types | |
enum | Parity { NONE_PARITY, EVEN_PARITY, ODD_PARITY, MARK_PARITY, SPACE_PARITY } |
Parity bit generation types. More... | |
enum | StopBits { STOP_BITS_1, STOP_BITS_1_5, STOP_BITS_2 } |
Number of stop bits. More... | |
enum | FlowControl { NONE_FLOW_CONTROL, HARDWARE_FLOW_CONTROL, SOFTWARE_FLOW_CONTROL } |
Flow control types. More... | |
typedef std::map< std::string, std::string > | RawConfigValues |
Raw configuration option -> values mapping. 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 | |
~SerialConfig () | |
Destructor. More... | |
SerialConfig (const SerialConfig &other) | |
Copy constructor. More... | |
SerialConfig & | operator= (const SerialConfig &other) |
Assignment operator. More... | |
bool | operator== (const SerialConfig &other) const |
Equality comparison. More... | |
bool | operator!= (const SerialConfig &other) const |
Non-equality comparison. More... | |
void | swap (SerialConfig &other) |
Swap the contents of this object with the other object. More... | |
std::string | getDevice () const |
Returns the serial port device. More... | |
speed_t | getSpeed () const |
Returns the serial port speed. More... | |
tcflag_t | getDataBits () const |
Returns the number of data bits. More... | |
Parity | getParity () const |
Returns the parity bit generation type. More... | |
StopBits | getStopBits () const |
Returns the number of stop bits. More... | |
FlowControl | getFlowControl () const |
Returns the flow control type. 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 SerialConfig | fromRawConfigValues (RawConfigValues rawConfigValues) |
Creates a SerialConfig 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... | |
Private Member Functions | |
SerialConfig () | |
Default constructor. More... | |
SerialConfig (Config::RawConfigValues rawConfigValues) | |
Constructor. More... | |
Static Private Member Functions | |
static std::string | parseDevice (const std::string &rawDevice) |
static speed_t | parseSpeed (const std::string &rawSpeed) |
static tcflag_t | parseDataBits (const std::string &rawDataBits) |
static Parity | parseParity (const std::string &rawParity) |
static StopBits | parseStopBits (const std::string &rawStopBits) |
static FlowControl | parseFlowControl (const std::string &rawFlowControl) |
Private Attributes | |
std::string | _device |
Serial port device. More... | |
speed_t | _speed |
Serial port speed (in baudes). More... | |
tcflag_t | _dataBits |
Number of data bits. More... | |
Parity | _parity |
Parity bit generation type. More... | |
StopBits | _stopBits |
Number of stop bits. More... | |
FlowControl | _flowControl |
Flow control type. More... | |
Static Private Attributes | |
static const std::string | DEFAULT_DEVICE |
Default interface. More... | |
static const speed_t | DEFAULT_SPEED |
Default speed. More... | |
static const tcflag_t | DEFAULT_DATA_BITS |
Default number of data bits. More... | |
static const Parity | DEFAULT_PARITY |
Default parity bit generation type. More... | |
static const StopBits | DEFAULT_STOP_BITS |
Default number of stop bits. More... | |
static const FlowControl | DEFAULT_FLOW_CONTROL |
Default flow control. 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 serial connection.
It provides value semantics (object copying and comparison is allowed).
typedef std::map<std::string, std::string> SerialConfig::RawConfigValues |
Raw configuration option -> values mapping.
enum SerialConfig::Parity |
SerialConfig::~SerialConfig | ( | ) |
Destructor.
Destroys a SerialConfig object.
SerialConfig::SerialConfig | ( | const SerialConfig & | 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 SerialConfig object.
|
private |
Constructor.
rawConfigValues | Raw configuration option -> values mappings. |
Constructs a TCPIPConfig object from the selected values.
|
static |
Creates a SerialConfig 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 number of data bits.
References _dataBits.
|
inline |
Returns the serial port device.
References _device.
|
inline |
Returns the flow control type.
References _flowControl.
|
inline |
Returns the parity bit generation type.
References _parity.
|
inline |
Returns the serial port speed.
References _speed.
|
inline |
Returns the number of stop bits.
References _stopBits.
bool SerialConfig::operator!= | ( | const SerialConfig & | other | ) | const |
Non-equality comparison.
other | Object that will be compared with this object. |
SerialConfig& SerialConfig::operator= | ( | const SerialConfig & | other | ) |
Assignment operator.
other | Object that will be assigned to this object. |
Guarantees the strong exception safety.
bool SerialConfig::operator== | ( | const SerialConfig & | other | ) | const |
Equality comparison.
other | Object that will be compared with this object. |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
void SerialConfig::swap | ( | SerialConfig & | 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 |
Number of data bits.
Referenced by getDataBits().
|
private |
Serial port device.
Referenced by getDevice().
|
private |
Flow control type.
Referenced by getFlowControl().
|
private |
Parity bit generation type.
Referenced by getParity().
|
private |
Serial port speed (in baudes).
Referenced by getSpeed().
|
private |
Number of stop bits.
Referenced by getStopBits().
|
staticprivate |
Default number of data bits.
|
staticprivate |
Default interface.
|
staticprivate |
Default flow control.
|
staticprivate |
Default parity bit generation type.
|
staticprivate |
Default speed.
|
staticprivate |
Default number of stop bits.