#include <events.h>
Public Types | |
enum | logtype_t { EVLOG_ERROR = 1, EVLOG_WARNING, EVLOG_INFO, EVLOG_DEBUG } |
Log Levels. More... | |
Public Member Functions | |
virtual SocketNotifier * | NewSocket (int fh, bool writable)=0 |
Factory interface for SocketNotifier objects. | |
virtual TimerNotifier * | NewTimer (void)=0 |
Factory interface for TimerNotifier objects. | |
virtual void | LogVa (logtype_t lt, const char *fmt, va_list ap)=0 |
Back-end Logging Function. | |
void | LogError (const char *fmt,...) __attribute__((format(printf |
Submit an error message to the application log. |
Most components of libhfp are event-driven state machines, and are designed to operate under a polling event loop. The DispatchInterface describes all methods that they use to schedule event notifications. Two types of notifications are required: socket (file handle) activity and timeouts. As an abstract interface, a DispatchInterface may be implemented for every environment that libhfp is to run in, e.g. Qt, Gtk+.
To adapt libhfp to a new environment, the DispatchInterface, SocketNotifier, and TimerNotifier interfaces must be implemented. An instance of the environment-specific DispatchInterface must then be provided as part of constructing most libhfp objects.
DispatchInterface is inherently single threaded and not meant for event dispatchers that support multithreading.
enum logtype_t |
Log Levels.
Log levels are used to express messages submitted by LogError(), LogWarn(), LogInfo(), and LogDebug() to LogVa(). With this, DispatchInterface implementations need only implement one virtual method to support logging.
virtual SocketNotifier* NewSocket | ( | int | fh, | |
bool | writable | |||
) | [pure virtual] |
Factory interface for SocketNotifier objects.
Creates an event dispatcher dependent SocketNotifier object that can be used to receive events on a specific socket.
fh | File handle to be monitored for activity | |
writable | true to notify on writability, false to notify on readability. |
virtual TimerNotifier* NewTimer | ( | void | ) | [pure virtual] |
Factory interface for TimerNotifier objects.
Creates an event dispatcher dependent TimerNotifier object that can be used to trigger time-based actions.
virtual void LogVa | ( | logtype_t | lt, | |
const char * | fmt, | |||
va_list | ap | |||
) | [pure virtual] |
Back-end Logging Function.
To support logging, a DispatchInterface derived class need only implement this method. The LogError(), LogWarn(), LogInfo(), and LogDebug() methods exist only as convenient frontends.