ZFFramework
 
Loading...
Searching...
No Matches
ZFTimer.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFTimer_h_
7#define _ZFI_ZFTimer_h_
8
9#include "ZFObject.h"
11
12zfclassFwd _ZFP_ZFTimerPrivate;
23zfclass ZFLIB_ZFCore ZFTimer : zfextend ZFObject, zfimplement ZFTaskId {
24 ZFOBJECT_DECLARE(ZFTimer, ZFObject)
25 ZFIMPLEMENT_DECLARE(ZFTaskId)
27 cache->stop();
28 cache->interval(1000);
29 })
30
31 // ============================================================
32 // observer events
33public:
40 ZFEVENT(TimerOnStart)
48 ZFEVENT(TimerOnActivate)
55 ZFEVENT(TimerOnStop)
56
57protected:
66 )
68 virtual void objectOnInit(void);
70 virtual void objectOnDealloc(void);
72 virtual void objectOnDeallocPrepare(void);
73
74public:
77
78public:
86
91
92public:
105
106public:
112
115
116public:
117 zffinal void _ZFP_ZFTimer_timerOnActivate(ZF_IN zfidentity timerImplId);
118protected:
120 virtual inline void timerOnStart(void) {
122 }
123
124 virtual inline void timerOnActivate(void) {
126 }
127
128 virtual inline void timerOnStop(void) {
130 }
131
132private:
133 _ZFP_ZFTimerPrivate *d;
134};
135
136// ============================================================
141 , ZFMP_IN(zftimet, interval)
142 , ZFMP_IN(const ZFListener &, timerCallback)
144
145
151 , ZFMP_IN(zftimet, delay)
152 , ZFMP_IN(const ZFListener &, timerCallback)
154
156#endif // #ifndef _ZFI_ZFTimer_h_
157
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
_zft_zftimet zftimet
time unit, ensured at least 64 bit, ensured signed
Definition ZFCoreTypeDef_CoreType.h:203
_zft_zfidentity zfidentity
identity type, ensured at least 32 bit, ensured unsigned
Definition ZFCoreTypeDef_CoreType.h:225
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:693
#define ZFMETHOD_FUNC_DECLARE_2(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:763
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
ZFObject related include.
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_ON_INIT_DECLARE_1(ZFMP_0)
see ZFOBJECT_ON_INIT_INLINE_1
Definition ZFObjectDeclare.h:263
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFIMPLEMENT_DECLARE(ImplementedInterfaces,...)
see ZFINTERFACE_DECLARE
Definition ZFObjectInterface.h:169
#define zfimplement
shows class implement from interface, see ZFInterface
Definition ZFObjectInterface.h:24
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
#define ZFALLOC_CACHE_RELEASE(action)
mark class that it should apply cache logic when alloc
Definition ZFObjectRetain.h:186
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
#define ZFPROPERTY_ON_UPDATE_DECLARE(Type, Name)
see ZFPROPERTY_ON_INIT_DECLARE
Definition ZFPropertyDeclare.h:238
zfautoT< ZFTimer > ZFTimerOnce(zftimet delay, const ZFListener &timerCallback)
util to start timer to run only once
zfautoT< ZFTimer > ZFTimerStart(zftimet interval, const ZFListener &timerCallback)
util to start timer
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
void observerNotify(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
notify the observer with eventId
timer utility
Definition ZFTimer.h:23
static zfidentity E_TimerOnStart(void)
see ZFObject::observerNotify
virtual void * nativeTimer()
for internal use only
virtual void stop()
stop the timer
virtual void objectOnInit(zftimet interval)
init with timer settings
static zfidentity E_TimerOnStop(void)
see ZFObject::observerNotify
virtual void timerOnStop(void)
see E_TimerOnStop
Definition ZFTimer.h:128
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
static zfidentity E_TimerOnActivate(void)
see ZFObject::observerNotify
virtual void objectOnDealloc(void)
override this to destroy your object
virtual void timerOnStart(void)
see E_TimerOnStart
Definition ZFTimer.h:120
virtual zfbool started()
true if started
zfidentity timerImplId(void)
internal timer id for impl only
virtual zfindex activatedCount()
get timer's current fired count, with 1 as first fired time's value, keep after timer stop,...
virtual zfbool & eventOnMainThread()
whether timer activate on main thread, true by default
Definition ZFTimer.h:90
virtual void start()
start the timer
virtual void timerOnActivate(void)
see E_TimerOnActivate
Definition ZFTimer.h:124
virtual zftimet & interval()
timer's interval when start a timer in mili seconds, default is 1000
Definition ZFTimer.h:84
type restrict version of zfauto
Definition zfautoFwd.h:110