ObjFW
|
00001 /* 00002 * Copyright (c) 2008, 2009, 2010, 2011, 2012 00003 * Jonathan Schleifer <js@webkeks.org> 00004 * 00005 * All rights reserved. 00006 * 00007 * This file is part of ObjFW. It may be distributed under the terms of the 00008 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in 00009 * the packaging of this file. 00010 * 00011 * Alternatively, it may be distributed under the terms of the GNU General 00012 * Public License, either version 2 or 3, which can be found in the file 00013 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this 00014 * file. 00015 */ 00016 00017 #import "OFObject.h" 00018 00019 @class OFString; 00020 @class OFArray; 00021 @class OFDictionary; 00022 @class OFMutableArray; 00023 @class OFMutableDictionary; 00024 00025 #define OF_APPLICATION_DELEGATE(cls) \ 00026 int \ 00027 main(int argc, char *argv[]) \ 00028 { \ 00029 return of_application_main(&argc, &argv, [cls class]); \ 00030 } 00031 00035 #ifndef OF_APPLICATION_M 00036 @protocol OFApplicationDelegate <OFObject> 00037 #else 00038 @protocol OFApplicationDelegate 00039 #endif 00040 00044 - (void)applicationDidFinishLaunching; 00045 00046 #ifdef OF_HAVE_OPTIONAL_PROTOCOLS 00047 @optional 00048 #endif 00049 00052 - (void)applicationWillTerminate; 00053 00062 - (void)applicationDidReceiveSIGINT; 00063 00064 #ifndef _WIN32 00065 00075 - (void)applicationDidReceiveSIGHUP; 00076 00087 - (void)applicationDidReceiveSIGUSR1; 00088 00099 - (void)applicationDidReceiveSIGUSR2; 00100 #endif 00101 @end 00102 00106 @interface OFApplication: OFObject 00107 { 00108 OFString *programName; 00109 OFMutableArray *arguments; 00110 OFMutableDictionary *environment; 00111 int *argc; 00112 char ***argv; 00113 @public 00114 id <OFApplicationDelegate> delegate; 00115 void (*SIGINTHandler)(id, SEL); 00116 #ifndef _WIN32 00117 void (*SIGHUPHandler)(id, SEL); 00118 void (*SIGUSR1Handler)(id, SEL); 00119 void (*SIGUSR2Handler)(id, SEL); 00120 #endif 00121 } 00122 00123 #ifdef OF_HAVE_PROPERTIES 00124 @property (readonly, assign) OFString *programName; 00125 @property (readonly, assign) OFArray *arguments; 00126 @property (readonly, assign) OFDictionary *environment; 00127 @property (assign) id <OFApplicationDelegate> delegate; 00128 #endif 00129 00135 + sharedApplication; 00136 00142 + (OFString*)programName; 00143 00149 + (OFArray*)arguments; 00150 00156 + (OFDictionary*)environment; 00157 00161 + (void)terminate; 00162 00168 + (void)terminateWithStatus: (int)status; 00169 00178 - (void)setArgumentCount: (int*)argc 00179 andArgumentValues: (char**[])argv; 00180 00187 - (void)getArgumentCount: (int**)argc 00188 andArgumentValues: (char***[])argv; 00189 00195 - (OFString*)programName; 00196 00202 - (OFArray*)arguments; 00203 00209 - (OFDictionary*)environment; 00210 00216 - (id <OFApplicationDelegate>)delegate; 00217 00223 - (void)setDelegate: (id <OFApplicationDelegate>)delegate; 00224 00230 - (void)run; 00231 00235 - (void)terminate; 00236 00242 - (void)terminateWithStatus: (int)status; 00243 @end 00244 00245 @interface OFObject (OFApplicationDelegate) <OFApplicationDelegate> 00246 @end 00247 00248 #ifdef __cplusplus 00249 extern "C" { 00250 #endif 00251 extern int of_application_main(int*, char**[], Class); 00252 #ifdef __cplusplus 00253 } 00254 #endif