#include <IOInterface.h>
Inheritance diagram for IOInterface:
Public Member Functions | |
IOInterface (IOInterfaceList *iolist) | |
Constructor. | |
~IOInterface () | |
Destructor. | |
IOInterfaceList * | GetIOInterfaceList () |
Returns the IOInterfaceList to which this IOInterface belongs to. | |
IOInterface * | GetIOInterfaceNext () |
Returns the next IOInterface in the list. | |
virtual void | OnInputAvailable () |
(abstract) This is called by the application when the filehandle has become active. | |
virtual void | OnDataArrival (unsigned char *data, int len)=0 |
(abstract) This is called by OnInputAvailable() to process data that arrived. | |
virtual void | OnClose ()=0 |
(abstract) This is called when the filehandle is closed. | |
virtual bool | Send (unsigned char *data, int len) |
(abstract) Writes data. | |
virtual bool | Send (const std::string &str) |
(abstract) Writes a string. | |
int | GetFileHandle () const |
Returns the file handle. | |
int | IsOpen () const |
Returns whether the IO is open. | |
bool | SetInputLogFile (const std::string &file, bool append=true) |
Sets the input log file. A copy of all input is saved in this file. If the string is empty, no log is saved. | |
bool | SetOutputLogFile (const std::string &file, bool append=true) |
Sets the output log file. A copy of all output is saved in this file. If the string is empty, no log is saved. | |
Protected Attributes | |
IOInterfaceList * | mIOInterfaceList |
The next IOInterface in the list. | |
IOInterface * | mIOInterfaceNext |
The next IOInterface in the list. | |
int | mFileHandle |
The file handle of the open file/device (or -1 if the file/device is closed). | |
std::ofstream | mLogInput |
The file where incoming traffic is logged. | |
std::ofstream | mLogOutput |
The file where outgoing traffic is logged. |
An IOInterface object is attached to a file handle. The application should invoke OnInputAvailable whenever the filehandle becomes active. This class then reads the new data and dispatches it.
Data can be sent using the Send() method.
All incoming and outgoing data can be logged to a file using SetInputLogFile() and SetOutputLogFile().
This is an abstract class. You need to overwrite at least the OnDataArrival() and the OnClose() methods.