The StreamController class is used to communicate with a device.
More...
#include <controller.hpp>
|
typedef StreamT | Stream |
| The stream type for this Controller.
|
|
|
| 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< ILog > | getLog () override |
| Get the current Log. More...
|
|
virtual std::shared_ptr< const ILog > | getLog () 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...
|
|
virtual std::string | sendCommand (const std::string &command) final override |
| Send a command to the device. More...
|
|
template<typename Response = void, typename Command > |
Response | sendCommand (const Command &command) |
| Send a command to the device. More...
|
|
template<typename Response = void, typename Command , typename... Args> |
Response | sendCommand (const Command &command, const Args &...params) |
| Send a command to the device. More...
|
|
template<typename Response = void, typename... Args> |
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...
|
|
template<typename... Args> |
std::string | createFormattedCommand (const std::string &commandFormat, Args...params) const |
| Create a command with the specified parameters (printf formatting is used). More...
|
|
virtual | ~IController ()=default |
| Default destructor.
|
|
virtual void | connect (const std::string &endpoint)=0 |
| Connect the controller to a device. More...
|
|
virtual std::string | getEndpoint () const =0 |
| Get the endpoint of device. More...
|
|
|
std::string | REQUEST_END = "\n" |
| A string that the request ends with.
|
|
std::string | RESPONSE_END = "\n" |
| A string that the response ends with.
|
|
bool | readResponse = true |
| If true the sendCommand method reads a response.
|
|
bool | readCommand = true |
| If true the input command is read from the response at first.
|
|
|
template<typename Response = void, typename std::enable_if< std::is_void< Response >::value >::type * = nullptr> |
void | sendCommand () |
| Send a command from the device input to the device.
|
|
template<typename Response , typename std::enable_if<!std::is_void< Response >::value >::type * = nullptr> |
Response | sendCommand () |
| Send a command from the device input to the device. More...
|
|
|
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.
|
|
StreamT | stream |
| A stream (TCP, socket, etc.) that is used for read/write operations.
|
|
std::shared_ptr< Log > | log |
| A log that is connected to the controller.
|
|
template<typename StreamT>
class regilo::StreamController< StreamT >
The StreamController class is used to communicate with a device.
template<typename StreamT >
Controller with a log file specified by a path.
- Parameters
-
logPath | Path to the log file. |
template<typename StreamT >
Controller with a log specified by a stream.
- Parameters
-
template<typename StreamT >
template<typename... Args>
std::string regilo::StreamController< StreamT >::createFormattedCommand |
( |
const std::string & |
commandFormat, |
|
|
Args... |
params |
|
) |
| const |
Create a command with the specified parameters (printf formatting is used).
- Parameters
-
commandFormat | A command format without parameters. |
params | Parameters that will be inserted into the command. |
- Returns
- The command with the parameters.
template<typename StreamT>
template<typename StreamT>
template<typename StreamT>
template<typename StreamT >
template<typename Response , typename std::enable_if<!std::is_void< Response >::value >::type * >
Send a command from the device input to the device.
- Returns
- A response to the command.
template<typename StreamT >
Send a command to the device.
- Parameters
-
command | A command with all parameters. |
- Returns
- A string with a whole response to the command.
Implements regilo::IController.
template<typename StreamT >
template<typename Response , typename Command >
Send a command to the device.
- Parameters
-
command | A command with all parameters. |
- Returns
- A response to the command.
template<typename StreamT >
template<typename Response , typename Command , typename... Args>
Send a command to the device.
- Parameters
-
command | A command without parameters. |
params | Parameters that will be inserted into the command (separated by space). |
- Returns
- A response to the command.
template<typename StreamT >
template<typename Response , typename... Args>
Response regilo::StreamController< StreamT >::sendFormattedCommand |
( |
const std::string & |
commandFormat, |
|
|
Args... |
params |
|
) |
| |
Create a command with the specified parameters (printf formatting is used) and send it to the device.
- Parameters
-
commandFormat | A command format without parameters. |
params | Parameters that will be inserted into the command. |
- Returns
- A response to the command.
template<typename StreamT >
Set a Log (it can be shared between more controllers).
- Parameters
-
log | Smart pointer to the Log. |
Implements regilo::IController.
The documentation for this class was generated from the following file: