1 /*
2  * Kiss - A refined core library for D programming language.
3  *
4  * Copyright (C) 2015-2018  Shanghai Putao Technology Co., Ltd
5  *
6  * Developer: HuntLabs.cn
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11  
12 module kiss.core;
13 
14 import core.time;
15 
16 // define kiss versions
17 enum KISS_MAJOR_VERSION = 0;
18 enum KISS_MINOR_VERSION = 4;
19 enum KISS_PATCH_VERSION = 5;
20 
21 /**
22 */
23 class EventArgs
24 {
25 
26 }
27 
28 alias EventHandler = void delegate(Object sender, EventArgs args);
29 alias SimpleEventHandler = void delegate();
30 alias ErrorEventHandler = void delegate(string message);
31 alias TickedEventHandler = void delegate(Object sender);
32 
33 /**
34 */
35 interface ITimer {
36     
37     /// 
38 	bool isActive();
39 
40 	/// in ms
41 	size_t interval();
42 
43 	/// ditto
44 	ITimer interval(size_t v);
45 	
46 	/// ditto
47 	ITimer interval(Duration duration);
48 
49 	///
50 	ITimer onTick(TickedEventHandler handler);
51 
52 	/// immediately: true to call first event immediately
53 	/// once: true to call timed event only once
54 	void start(bool immediately = false, bool once = false);
55 	
56 	void stop();
57 
58 	void reset(bool immediately = false, bool once = false);
59 
60 	void reset(size_t interval);
61 
62 	void reset(Duration duration);
63 }
64 
65 bool isCompilerVersionAbove(int ver)
66 {
67     return __VERSION__ >= ver;
68 }
69 
70 bool isCompilerVersionBelow(int ver)
71 {
72     return __VERSION__ <= ver;
73 }