ObjFW
 All Classes Functions Variables
OFTimer.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 
19 @class OFTimer;
20 @class OFDate;
21 @class OFCondition;
22 
23 #ifdef OF_HAVE_BLOCKS
24 typedef void (^of_timer_block_t)(OFTimer*);
25 #endif
26 
31 {
33  double interval;
34  id target, object1, object2;
35  SEL selector;
36  uint8_t arguments;
37  BOOL repeats;
38 #ifdef OF_HAVE_BLOCKS
39  of_timer_block_t block;
40 #endif
41  BOOL isValid, done;
42  OFCondition *condition;
43 }
44 
45 #ifdef OF_HAVE_PROPERTIES
46 @property (readonly, retain) OFDate *fireDate;
47 #endif
48 
59 + (instancetype)scheduledTimerWithTimeInterval: (double)interval
60  target: (id)target
61  selector: (SEL)selector
62  repeats: (BOOL)repeats;
63 
75 + (instancetype)scheduledTimerWithTimeInterval: (double)interval
76  target: (id)target
77  selector: (SEL)selector
78  object: (id)object
79  repeats: (BOOL)repeats;
80 
95 + (instancetype)scheduledTimerWithTimeInterval: (double)interval
96  target: (id)target
97  selector: (SEL)selector
98  object: (id)object1
99  object: (id)object2
100  repeats: (BOOL)repeats;
101 
102 #ifdef OF_HAVE_BLOCKS
103 
112 + (instancetype)scheduledTimerWithTimeInterval: (double)interval
113  repeats: (BOOL)repeats
114  block: (of_timer_block_t)block;
115 #endif
116 
127 + (instancetype)timerWithTimeInterval: (double)interval
128  target: (id)target
129  selector: (SEL)selector
130  repeats: (BOOL)repeats;
131 
143 + (instancetype)timerWithTimeInterval: (double)interval
144  target: (id)target
145  selector: (SEL)selector
146  object: (id)object
147  repeats: (BOOL)repeats;
148 
163 + (instancetype)timerWithTimeInterval: (double)interval
164  target: (id)target
165  selector: (SEL)selector
166  object: (id)object1
167  object: (id)object2
168  repeats: (BOOL)repeats;
169 
170 #ifdef OF_HAVE_BLOCKS
171 
180 + (instancetype)timerWithTimeInterval: (double)interval
181  repeats: (BOOL)repeats
182  block: (of_timer_block_t)block;
183 #endif
184 
197 - initWithFireDate: (OFDate*)fireDate
198  interval: (double)interval
199  target: (id)target
200  selector: (SEL)selector
201  repeats: (BOOL)repeats;
202 
216 - initWithFireDate: (OFDate*)fireDate
217  interval: (double)interval
218  target: (id)target
219  selector: (SEL)selector
220  object: (id)object
221  repeats: (BOOL)repeats;
222 
239 - initWithFireDate: (OFDate*)fireDate
240  interval: (double)interval
241  target: (id)target
242  selector: (SEL)selector
243  object: (id)object1
244  object: (id)object2
245  repeats: (BOOL)repeats;
246 
247 #ifdef OF_HAVE_BLOCKS
248 
259 - initWithFireDate: (OFDate*)fireDate
260  interval: (double)interval
261  repeats: (BOOL)repeats
262  block: (of_timer_block_t)block;
263 #endif
264 
269 - (void)fire;
270 
276 - (OFDate*)fireDate;
277 
281 - (void)invalidate;
282 
288 - (BOOL)isValid;
289 
297 - (double)timeInterval;
298 
302 - (void)waitUntilDone;
303 @end