Commander-API  V2.1.0
Simple Command Parser
Loading...
Searching...
No Matches
commandResponse Class Reference

Default response class. More...

#include <Commander-IO.hpp>

Inheritance diagram for commandResponse:
[legend]
Collaboration diagram for commandResponse:
[legend]

Public Member Functions

int available ()
 Available bytes in the channel. More...
 
int read ()
 Read one byte form the channel. More...
 
int peek ()
 Peek the firtst byte from the channel. More...
 
void flush ()
 Flush the channel. More...
 
size_t write (uint8_t b)
 Write one byte to the channel. More...
 

Detailed Description

Default response class.

This base class is responsible to create a communication channel between the function associated with a command and the sender entity. This entity can be anything like Serial, Client... Because every function in this class is virtual, it means that they can be overridden with subclasses. It is useful, because if we make a subclass for every entity that can communicate with Commander, we can automatically pair the right function for that entity. The base class doesn't do much. To make it any use, we have to create a subclass for it like below.

Definition at line 72 of file Commander-IO.hpp.

Member Function Documentation

◆ available()

int commandResponse::available ( )
inline

Available bytes in the channel.

Returns
The available bytes in the channel. Because it is the base class, it returns 0.

Definition at line 79 of file Commander-IO.hpp.

◆ flush()

void commandResponse::flush ( )
inline

Flush the channel.

Definition at line 92 of file Commander-IO.hpp.

◆ peek()

int commandResponse::peek ( )
inline

Peek the firtst byte from the channel.

Returns
Read and return one byte form the channel. The byte will NOT be removed from the channel. Because it is the base class, it returns 0.

Definition at line 89 of file Commander-IO.hpp.

◆ read()

int commandResponse::read ( )
inline

Read one byte form the channel.

Returns
Read and return one byte form the channel. The byte will be removed from the channel. Because it is the base class, it returns -1.

Definition at line 84 of file Commander-IO.hpp.

◆ write()

size_t commandResponse::write ( uint8_t  b)
inline

Write one byte to the channel.

Parameters
bThe value that has to be written to the channel.
Returns
The number of bytes that has been sucessfully written to the channel. Because it is the base class, it returns 0.

Definition at line 98 of file Commander-IO.hpp.