ObjFW
 All Classes Functions Variables
OFApplication.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 OFString;
20 @class OFArray;
21 @class OFDictionary;
22 @class OFMutableArray;
23 @class OFMutableDictionary;
24 
25 #define OF_APPLICATION_DELEGATE(cls) \
26  int \
27  main(int argc, char *argv[]) \
28  { \
29  return of_application_main(&argc, &argv, [cls class]); \
30  }
31 
35 #ifndef OF_APPLICATION_M
37 #else
38 @protocol OFApplicationDelegate
39 #endif
40 
45 
46 #ifdef OF_HAVE_OPTIONAL_PROTOCOLS
47 @optional
48 #endif
49 
53 
63 
64 #ifndef _WIN32
65 
76 
88 
100 #endif
101 @end
102 
107 {
111  int *argc;
112  char ***argv;
113 @public
114  id <OFApplicationDelegate> delegate;
115  void (*SIGINTHandler)(id, SEL);
116 #ifndef _WIN32
117  void (*SIGHUPHandler)(id, SEL);
118  void (*SIGUSR1Handler)(id, SEL);
119  void (*SIGUSR2Handler)(id, SEL);
120 #endif
121 }
122 
123 #ifdef OF_HAVE_PROPERTIES
124 @property (readonly, copy, nonatomic) OFString *programName;
125 @property (readonly, copy, nonatomic) OFArray *arguments;
126 @property (readonly, copy, nonatomic) OFDictionary *environment;
127 @property (assign) id <OFApplicationDelegate> delegate;
128 #endif
129 
135 + (OFApplication*)sharedApplication;
136 
142 + (OFString*)programName;
143 
149 + (OFArray*)arguments;
150 
156 + (OFDictionary*)environment;
157 
161 + (void)terminate;
162 
168 + (void)terminateWithStatus: (int)status;
169 
178 - (void)setArgumentCount: (int*)argc
179  andArgumentValues: (char**[])argv;
180 
187 - (void)getArgumentCount: (int**)argc
188  andArgumentValues: (char***[])argv;
189 
195 - (OFString*)programName;
196 
202 - (OFArray*)arguments;
203 
209 - (OFDictionary*)environment;
210 
216 - (id <OFApplicationDelegate>)delegate;
217 
223 - (void)setDelegate: (id <OFApplicationDelegate>)delegate;
224 
230 - (void)run;
231 
235 - (void)terminate;
236 
242 - (void)terminateWithStatus: (int)status;
243 @end
244 
245 @interface OFObject (OFApplicationDelegate) <OFApplicationDelegate>
246 @end
247 
248 #ifdef __cplusplus
249 extern "C" {
250 #endif
251 extern int of_application_main(int*, char**[], Class);
252 #ifdef __cplusplus
253 }
254 #endif