ObjFW
OFApplication.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
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 OF_ASSUME_NONNULL_BEGIN
20 
21 @class OFString;
22 #ifndef DOXYGEN
23 @class OFArray OF_GENERIC(ObjectType);
24 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
25 @class OFMutableArray OF_GENERIC(ObjectType);
26 @class OFMutableDictionary OF_GENERIC(KeyType, ObjectType);
27 #endif
28 
29 #define OF_APPLICATION_DELEGATE(cls) \
30  int \
31  main(int argc, char *argv[]) \
32  { \
33  return of_application_main(&argc, &argv, [cls class]); \
34  }
35 
47 
48 #ifdef OF_HAVE_OPTIONAL_PROTOCOLS
49 @optional
50 #endif
51 
55 
65 
66 #ifndef _WIN32
67 
78 
90 
102 #endif
103 @end
104 
117 {
118  OFString *_programName;
119  OFArray OF_GENERIC(OFString*) *_arguments;
120  OFDictionary OF_GENERIC(OFString*, OFString*) *_environment;
121  int *_argc;
122  char ***_argv;
123 @public
124  id <OFApplicationDelegate> _delegate;
125  void (*_SIGINTHandler)(id, SEL);
126 #ifndef _WIN32
127  void (*_SIGHUPHandler)(id, SEL);
128  void (*_SIGUSR1Handler)(id, SEL);
129  void (*_SIGUSR2Handler)(id, SEL);
130 #endif
131 }
132 
133 #ifdef OF_HAVE_PROPERTIES
134 @property (readonly, copy, nonatomic) OFString *programName;
135 @property (readonly, copy, nonatomic) OFArray OF_GENERIC(OFString*) *arguments;
136 @property (readonly, copy, nonatomic)
137  OFDictionary OF_GENERIC(OFString*, OFString*) *environment;
138 @property OF_NULLABLE_PROPERTY (assign) id <OFApplicationDelegate> delegate;
139 #endif
140 
146 + (OFApplication*)sharedApplication;
147 
153 + (OFString*)programName;
154 
160 + (OFArray OF_GENERIC(OFString*)*)arguments;
161 
167 + (OFDictionary OF_GENERIC(OFString*, OFString*)*)environment;
168 
172 + (void)terminate OF_NO_RETURN;
173 
179 + (void)terminateWithStatus: (int)status OF_NO_RETURN;
180 
187 - (void)getArgumentCount: (int *OF_NONNULL *OF_NONNULL)argc
188  andArgumentValues: (char *OF_NONNULL *OF_NONNULL *OF_NONNULL[])argv;
189 
195 - (OFString*)programName;
196 
202 - (OFArray OF_GENERIC(OFString*)*)arguments;
203 
209 - (OFDictionary OF_GENERIC(OFString*, OFString*)*)environment;
210 
216 - (nullable id <OFApplicationDelegate>)delegate;
217 
223 - (void)setDelegate: (nullable id <OFApplicationDelegate>)delegate;
224 
228 - (void)terminate OF_NO_RETURN;
229 
235 - (void)terminateWithStatus: (int)status OF_NO_RETURN;
236 @end
237 
238 @interface OFObject (OFApplicationDelegate) <OFApplicationDelegate>
239 @end
240 
241 #ifdef __cplusplus
242 extern "C" {
243 #endif
244 extern int of_application_main(int *OF_NONNULL, char *OF_NONNULL *OF_NONNULL[],
245  Class);
246 #ifdef __cplusplus
247 }
248 #endif
249 
250 OF_ASSUME_NONNULL_END
void applicationDidReceiveSIGUSR2()
A method which is called when the application received a SIGUSR2.
An abstract class for storing objects in an array.
Definition: OFArray.h:95
void applicationDidFinishLaunching()
A method which is called when the application was initialized and is running now. ...
void applicationDidReceiveSIGHUP()
A method which is called when the application received a SIGHUP.
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
An abstract class for storing, adding and removing objects in an array.
Definition: OFMutableArray.h:46
void applicationWillTerminate()
A method which is called when the application will terminate.
A class for handling strings.
Definition: OFString.h:91
void applicationDidReceiveSIGINT()
A method which is called when the application received a SIGINT.
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:61
An abstract class for storing and changing objects in a dictionary.
Definition: OFMutableDictionary.h:47
A protocol for delegates of OFApplication.
Definition: OFApplication.h:41
A class which represents the application as an object.
Definition: OFApplication.h:116
void applicationDidReceiveSIGUSR1()
A method which is called when the application received a SIGUSR1.