1 /* Declarations for NSTimer for GNUStep
2    Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
3 
4    Written by:  Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
5    Date: 1995
6 
7    This file is part of the GNUstep Base Library.
8 
9    This library is free software; you can redistribute it and/or
10    modify it under the terms of the GNU Lesser General Public
11    License as published by the Free Software Foundation; either
12    version 2 of the License, or (at your option) any later version.
13 
14    This library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    Lesser General Public License for more details.
18 
19    You should have received a copy of the GNU Lesser General Public
20    License along with this library; if not, write to the Free
21    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22    Boston, MA 02110 USA.
23    */
24 
25 #ifndef __NSTimer_h_GNUSTEP_BASE_INCLUDE
26 #define __NSTimer_h_GNUSTEP_BASE_INCLUDE
27 #import	<GNUstepBase/GSVersionMacros.h>
28 
29 #import	<Foundation/NSDate.h>
30 
31 @class NSTimer;
32 DEFINE_BLOCK_TYPE(GSTimerBlock, void, NSTimer*);
33 
34 #if	defined(__cplusplus)
35 extern "C" {
36 #endif
37 
38 /*
39  *	NB. NSRunLoop is optimised using a hack that knows about the
40  *	class layout for the fire date and invialidation flag in NSTimer.
41  *	These MUST remain the first two items in the class.
42  *	Other classes must not attempt to use instance variables as
43  *	they are subject to change.
44  */
45 @interface NSTimer : NSObject
46 {
47 #if	GS_EXPOSE(NSTimer)
48 @public
49   NSDate 	 *_date;	/* Must be 1st - for NSRunLoop optimisation */
50   BOOL		 _invalidated;	/* Must be 2nd - for NSRunLoop optimisation */
51   BOOL		 _repeats;
52   NSTimeInterval _interval;
53   id		 _target;
54   SEL		 _selector;
55   id		 _info;
56   GSTimerBlock   _block;
57 #endif
58 #if     GS_NONFRAGILE
59 #else
60   /* Pointer to private additional data used to avoid breaking ABI
61    * when we don't have the non-fragile ABI available.
62    * Use this mechanism rather than changing the instance variable
63    * layout (see Source/GSInternal.h for details).
64    */
65   @private id _internal GS_UNUSED_IVAR;
66 #endif
67 }
68 
69 /* Creating timer objects. */
70 
71 + (NSTimer*) scheduledTimerWithTimeInterval: (NSTimeInterval)ti
72 				 invocation: (NSInvocation*)invocation
73 				    repeats: (BOOL)f;
74 
75 + (NSTimer*) scheduledTimerWithTimeInterval: (NSTimeInterval)ti
76 				     target: (id)object
77 				   selector: (SEL)selector
78 				   userInfo: (id)info
79 				    repeats: (BOOL)f;
80 
81 + (NSTimer *) scheduledTimerWithTimeInterval: (NSTimeInterval)ti
82                                      repeats: (BOOL)f
83                                        block: (GSTimerBlock)block;
84 
85 + (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
86 		        invocation: (NSInvocation*)invocation
87 			   repeats: (BOOL)f;
88 
89 + (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
90 			    target: (id)object
91 			  selector: (SEL)selector
92 			  userInfo: (id)info
93 			   repeats: (BOOL)f;
94 
95 - (void) fire;
96 - (NSDate*) fireDate;
97 - (void) invalidate;
98 - (id) userInfo;
99 
100 #if	OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
101 - (BOOL) isValid;
102 - (NSTimeInterval) timeInterval;
103 #endif
104 
105 #if	OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
106 - (id) initWithFireDate: (NSDate*)fd
107 	       interval: (NSTimeInterval)ti
108 		 target: (id)object
109 	       selector: (SEL)selector
110 	       userInfo: (id)info
111 		repeats: (BOOL)f;
112 - (void) setFireDate: (NSDate*)fireDate;
113 #endif
114 
115 #if	OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
116 - (instancetype) initWithFireDate: (NSDate *)date
117                          interval: (NSTimeInterval)interval
118                           repeats: (BOOL)repeats
119                             block: (GSTimerBlock)block;
120 #endif
121 
122 @end
123 
124 #if	defined(__cplusplus)
125 }
126 #endif
127 
128 #endif	/* __NSTimer_h_GNUSTEP_BASE_INCLUDE */
129