OpenDaVINCI  4.15.3
odcore::io::protocol::StringProtocol Class Reference

#include <StringProtocol.h>

Inheritance diagram for odcore::io::protocol::StringProtocol:
Inheritance graph

Public Member Functions

 StringProtocol ()
 
virtual ~StringProtocol ()
 
void send (const string &data)
 
void setStringListener (StringListener *listener)
 
virtual void nextString (const string &s)
 
void setStringSender (StringSender *sender)
 
void sendByStringSender (const string &data)
 

Detailed Description

This class implements a simple string protocol having the format:

 size payload

The size is encoded as a 4 byte network byte order unsigned integer.

Constructor & Destructor Documentation

odcore::io::protocol::StringProtocol::StringProtocol ( )

Constructor.

odcore::io::protocol::StringProtocol::~StringProtocol ( )
virtual

References setStringListener().

Member Function Documentation

void odcore::io::protocol::StringProtocol::nextString ( const string &  s)
virtual

This method is called whenever a new string occurs.

Parameters
sString that has been occured.

Implements odcore::io::StringListener.

void odcore::io::protocol::StringProtocol::send ( const string &  data)

This method sends the data in the following format:

size data

Size: htonl((uint32_t) data.length())

Parameters
dataData to be sent.

References odcore::io::protocol::AbstractProtocol::sendByStringSender().

void odcore::io::protocol::AbstractProtocol::sendByStringSender ( const string &  data)
inherited

This method needs to be called by subclasses to actually send some data according to the implemented protocol.

Parameters
dataData to be sent.

References odcore::io::StringSender::send().

Referenced by send(), and odcore::io::protocol::NetstringsProtocol::send().

void odcore::io::protocol::StringProtocol::setStringListener ( StringListener listener)
virtual

This method sets the StringListener that will receive incoming data.

Parameters
listenerStringListener that will receive incoming data.

Implements odcore::io::StringObserver.

Referenced by ~StringProtocol().

void odcore::io::protocol::AbstractProtocol::setStringSender ( StringSender sender)
inherited

This method sets the StringSender (implemented by a connection like SerialPort) that can actually send the data.

Parameters
senderStringSender that will send the data.

Referenced by odcore::io::protocol::AbstractProtocol::~AbstractProtocol().