1 /******************************************************************************* 2 3 Interface for Application extensions. 4 5 Copyright: 6 Copyright (c) 2009-2016 dunnhumby Germany GmbH. 7 All rights reserved. 8 9 License: 10 Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. 11 Alternatively, this file may be distributed under the terms of the Tango 12 3-Clause BSD License (see LICENSE_BSD.txt for details). 13 14 *******************************************************************************/ 15 16 module ocean.util.app.model.IApplicationExtension; 17 18 19 20 21 import ocean.meta.types.Qualifiers; 22 23 public import ocean.util.app.ExitException : ExitException; 24 25 import ocean.util.app.model.IExtension; 26 import ocean.util.app.model.IApplication; 27 28 29 30 /******************************************************************************* 31 32 Interface for Application extensions. 33 34 *******************************************************************************/ 35 36 interface IApplicationExtension : IExtension 37 { 38 39 /*************************************************************************** 40 41 Alias of IApplication, for use by implementing classes without needing 42 to import ocean.util.app.model.IApplication. 43 44 ***************************************************************************/ 45 46 alias .IApplication IApplication; 47 48 49 /*************************************************************************** 50 51 Function executed before the program runs. 52 53 Params: 54 app = the application instance that will run 55 args = command line arguments used to invoke the application 56 57 ***************************************************************************/ 58 59 void preRun ( IApplication app, istring[] args ); 60 61 62 /*************************************************************************** 63 64 Function executed after the program runs. 65 66 This will only be called if the program runs completely and the 67 Application.exit() method was not called. 68 69 Params: 70 app = the application instance that will run 71 args = command line arguments used to invoke the application 72 status = exit status returned by the application 73 74 ***************************************************************************/ 75 76 void postRun ( IApplication app, istring[] args, int status ); 77 78 79 /*************************************************************************** 80 81 Function executed at program exit. 82 83 This is function is executed always just before the program exits, no 84 matter if Application.exit() was called or not. This function can be 85 useful to do application cleanup that's always needed. 86 87 Params: 88 app = the application instance that will run 89 args = command line arguments used to invoke the application 90 status = exit status returned by the application 91 exception = exit exception instance, if one was thrown (null 92 otherwise) 93 94 Returns: 95 new exit exception to use when the program exits (can be modified by 96 other extension though) 97 98 ***************************************************************************/ 99 100 void atExit ( IApplication app, istring[] args, int status, 101 ExitException exception ); 102 103 104 /*************************************************************************** 105 106 Function executed if (and only if) an ExitException was thrown. 107 108 It can change the ExitException to change how the program will exit. 109 110 Params: 111 app = the application instance that will run 112 args = command line arguments used to invoke the application 113 exception = current exit exception that will be used to exit 114 115 Returns: 116 new exit exception to use when the program exits (can be modified by 117 other extension though) 118 119 ***************************************************************************/ 120 121 ExitException onExitException ( IApplication app, istring[] args, 122 ExitException exception ); 123 124 }