Async 1.5.0
|
A class for watching file descriptors. More...
#include <AsyncFdWatch.h>
Public Types | |
enum | FdWatchType { FD_WATCH_RD , FD_WATCH_WR } |
The type of the file descriptor watch. More... | |
Public Member Functions | |
FdWatch (void) | |
Default constructor. | |
FdWatch (int fd, FdWatchType type) | |
Constructor. | |
~FdWatch (void) | |
Destructor. | |
int | fd (void) const |
Return the file descriptor being watched. | |
FdWatchType | type (void) const |
Return the type of this watch. | |
void | setEnabled (bool enabled) |
Enable or disable the watch. | |
bool | isEnabled (void) const |
Check if the watch is enabled or not. | |
void | setFd (int fd, FdWatchType type) |
Set the file descriptor to watch. | |
Public Attributes | |
sigc::signal< void, FdWatch * > | activity |
Signal to indicate that the descriptor is active. | |
A class for watching file descriptors.
Use this class to watch a file descriptor for activity. The example below creates a read watch on the standard input file descriptor. That is, every time a character is typed on the keyboard (or something is piped to the application) the onActivity method in instance this of class MyClass will be called. In the handler function, the data on the file descriptor should be read. Otherwise the handler function will be called over and over again.
Definition at line 119 of file AsyncFdWatch.h.
The type of the file descriptor watch.
Enumerator | |
---|---|
FD_WATCH_RD | File descriptor watch for incoming data. |
FD_WATCH_WR | File descriptor watch for outgoing data. |
Definition at line 125 of file AsyncFdWatch.h.
Async::FdWatch::FdWatch | ( | void | ) |
Default constructor.
Create a disabled FdWatch. Use the setFd function to set the filedescriptor to watch and the type of watch.
Async::FdWatch::FdWatch | ( | int | fd, |
FdWatchType | type | ||
) |
Constructor.
Add the given file descriptor to the watch list and watch it for incoming data (FD_WATCH_RD) or write buffer space available (FD_WATCH_WR).
fd | The file descriptor to watch |
type | The type of watch to create (see FdWatchType) |
Async::FdWatch::~FdWatch | ( | void | ) |
Destructor.
|
inline |
Return the file descriptor being watched.
Definition at line 159 of file AsyncFdWatch.h.
|
inline |
Check if the watch is enabled or not.
Definition at line 178 of file AsyncFdWatch.h.
void Async::FdWatch::setEnabled | ( | bool | enabled | ) |
Enable or disable the watch.
enabled | Set to true to enable the watch or false to disable it. |
void Async::FdWatch::setFd | ( | int | fd, |
FdWatchType | type | ||
) |
Set the file descriptor to watch.
fd | The file descriptor to watch |
type | The type of watch to create (see FdWatchType) |
This function can be used at any time to change the file descriptor or type of watch. If the watch was disabled it will stay disabled until explicitly being enabled.
|
inline |
Return the type of this watch.
Definition at line 165 of file AsyncFdWatch.h.
sigc::signal<void, FdWatch*> Async::FdWatch::activity |
Signal to indicate that the descriptor is active.
watch | Pointer to the watch object |
Definition at line 195 of file AsyncFdWatch.h.