IEventHandler类

2013年6月14日 由 Creater 留言 »

该类用来管理 Timer events,是一个纯虚的基类。
IEventHandler并不是直接与 Timer events打交道,而是透过IEventOwner交互。凡是想使用 Timer events的类都需要继承自IEventOwner。
IEventOwner是一个 Timer events的拥有者,IEventHandler则是对 Timer events进行处理。

#ifndef _SOCKETS_IEventHandler_H
#define _SOCKETS_IEventHandler_H

#include "sockets-config.h"

#ifdef SOCKETS_NAMESPACE
namespace SOCKETS_NAMESPACE {
#endif


class IEventOwner;

/** Timer event handler pure virtual base class.
	\ingroup timer */
class IEventHandler
{
public:
	virtual ~IEventHandler() {}

	/** Return time left until next event.
		\param tv Time struct that will be filled by method
		\return true if time is set for next event */
	virtual bool GetTimeUntilNextEvent(struct timeval *) = 0;
	/** Will fire events whose time has come. */
	virtual void CheckEvents() = 0;
	/** Schedule event for an owner.
		\param from Event owner
		\param sec Seconds until event
		\param usec Microseconds until event */
	virtual long AddEvent(IEventOwner *,long sec,long usec) = 0;
	/** Clear all events for a specific owner. */
	virtual void ClearEvents(IEventOwner *) = 0;
	/** Remove one specific event for an event owner. */
	virtual void RemoveEvent(IEventOwner *,long) = 0;

};

#ifdef SOCKETS_NAMESPACE
}
#endif

#endif // _SOCKETS_IEventHandler_H
广告位

发表评论

你必须 登陆 方可发表评论.