Regilo
A simple C++ library for controlling the Neato XV robot and the Hokuyo scanner.
regilo::SocketController Class Reference

The SocketController class is used to communicate with a device using a TCP socket. More...

#include <socketcontroller.hpp>

Inheritance diagram for regilo::SocketController:
regilo::StreamController< bai::tcp::socket > regilo::IController

Public Member Functions

virtual ~SocketController ()
 Default destructor.
 
virtual void connect (const std::string &endpoint) override
 Connect the controller to a device. More...
 
void connect (const std::string &ip, unsigned short port)
 Connect the controller to a device. More...
 
void connect (const bai::tcp::endpoint &endpoint)
 Connect the controller to a device. More...
 
virtual std::string getEndpoint () const override
 Get the endpoint of device. More...
 
- Public Member Functions inherited from regilo::StreamController< bai::tcp::socket >
virtual std::string sendCommand (const std::string &command) final override
 Send a command to the device. More...
 
Response sendCommand (const Command &command)
 Send a command to the device. More...
 
Response sendCommand (const Command &command, const Args &...params)
 Send a command to the device. More...
 
 StreamController ()
 Default constructor.
 
 StreamController (const std::string &logPath)
 Controller with a log file specified by a path. More...
 
 StreamController (std::iostream &logStream)
 Controller with a log specified by a stream. More...
 
virtual ~StreamController ()
 Default destructor.
 
virtual bool isConnected () const override
 Test if the controller is connected. More...
 
virtual std::shared_ptr< ILoggetLog () override
 Get the current Log. More...
 
virtual std::shared_ptr< const ILoggetLog () const override
 Get the current Log (a const variant). More...
 
virtual void setLog (std::shared_ptr< ILog > log) override
 Set a Log (it can be shared between more controllers). More...
 
Response sendFormattedCommand (const std::string &commandFormat, Args...params)
 Create a command with the specified parameters (printf formatting is used) and send it to the device. More...
 
std::string createFormattedCommand (const std::string &commandFormat, Args...params) const
 Create a command with the specified parameters (printf formatting is used). More...
 
- Public Member Functions inherited from regilo::IController
virtual ~IController ()=default
 Default destructor.
 

Additional Inherited Members

- Public Types inherited from regilo::StreamController< bai::tcp::socket >
typedef bai::tcp::socket Stream
 The stream type for this Controller.
 
- Public Attributes inherited from regilo::StreamController< bai::tcp::socket >
std::string REQUEST_END
 A string that the request ends with.
 
std::string RESPONSE_END
 A string that the response ends with.
 
bool readResponse
 If true the sendCommand method reads a response.
 
bool readCommand
 If true the input command is read from the response at first.
 
- Protected Member Functions inherited from regilo::StreamController< bai::tcp::socket >
void sendCommand ()
 Send a command from the device input to the device.
 
Response sendCommand ()
 Send a command from the device input to the device. More...
 
- Protected Attributes inherited from regilo::StreamController< bai::tcp::socket >
std::istringstream deviceOutput
 A buffer for the device output.
 
std::ostringstream deviceInput
 A buffer for the device input.
 
ba::io_service ioService
 The Boost IO service.
 
bai::tcp::socket stream
 A stream (TCP, socket, etc.) that is used for read/write operations.
 
std::shared_ptr< Loglog
 A log that is connected to the controller.
 

Detailed Description

The SocketController class is used to communicate with a device using a TCP socket.

Member Function Documentation

virtual void regilo::SocketController::connect ( const std::string &  endpoint)
overridevirtual

Connect the controller to a device.

Parameters
endpointThe endpoint with the IP address and port of the device (e.g. "10.0.0.1:12345").

Implements regilo::IController.

void regilo::SocketController::connect ( const std::string &  ip,
unsigned short  port 
)

Connect the controller to a device.

Parameters
ipThe IP address of the device (e.g. "10.0.0.1").
portThe port number of the device (e.g. 12345).
void regilo::SocketController::connect ( const bai::tcp::endpoint &  endpoint)

Connect the controller to a device.

Parameters
endpointThe endpoint of the device.
virtual std::string regilo::SocketController::getEndpoint ( ) const
overridevirtual

Get the endpoint of device.

Returns
The device endpoint or empty string.

Implements regilo::IController.


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