hoople_main.h

Go to the documentation of this file.
00001 #ifndef HOOPLE_MAIN_GROUP
00002 #define HOOPLE_MAIN_GROUP
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : HOOPLE_MAIN group
00007 *  Author : Chris Koeritz
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2000-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00019 
00020 #include "application_shell.h"
00021 #include "command_line.h"
00022 #include "windoze_helper.h"
00023 
00024 #include <basis/contracts.h>
00025 #include <loggers/critical_events.h>
00026 #include <loggers/combo_logger.h>
00027 #include <structures/static_memory_gremlin.h>
00028 #include <loggers/program_wide_logger.h>
00029 
00030 namespace application {
00031 
00032 // The following versions of main programs are provided for different operating
00033 // systems and compilation environments.  These support the requirements of the
00034 // HOOPLE startup code and program-wide features, assuming an object derived
00035 // from base_application is available.
00036 // The object derived from base_application must be provided in "obj_name".
00037 // The "obj_args" are any arguments that need to be passed to the object's
00038 // constructor; this list can be empty.
00039 // Note that the default logger used for unix and console mode win32 programs
00040 // is the console logger; that can be changed in the startup code for the
00041 // "obj_name".
00042 
00043 #define HOOPLE_STARTUP_CODE \
00044   DEFINE_INSTANCE_HANDLE;
00045 
00046 #ifdef __WXWIDGETS__
00047 
00048   #define HOOPLE_MAIN(obj_name, obj_args) \
00049     HOOPLE_STARTUP_CODE; \
00050     int main(int argc, char *argv[]) { \
00051       SET_ARGC_ARGV(argc, argv); \
00052       SETUP_COMBO_LOGGER; \
00053       obj_name to_run_obj obj_args; \
00054       return to_run_obj.execute_application(); \
00055     }
00056 
00058 
00059 #elif defined(__UNIX__)
00060 
00061   #define HOOPLE_MAIN(obj_name, obj_args) \
00062     HOOPLE_STARTUP_CODE; \
00063     int main(int argc, char *argv[]) { \
00064       SET_ARGC_ARGV(argc, argv); \
00065       SETUP_COMBO_LOGGER; \
00066       obj_name to_run_obj obj_args; \
00067       return to_run_obj.execute_application(); \
00068     }
00069 
00071 
00072 #elif defined(__WIN32__)
00073   // for win32 we need to support four different environments--console mode,
00074   // borland compilation, MFC programs and regular windows programs.
00075   #ifdef _CONSOLE
00076 
00077     #define HOOPLE_MAIN(obj_name, obj_args) \
00078       HOOPLE_STARTUP_CODE; \
00079       int main(int argc, char *argv[]) { \
00080         SETUP_COMBO_LOGGER; \
00081         SET_ARGC_ARGV(argc, argv); \
00082         obj_name to_run_obj obj_args; \
00083         return to_run_obj.execute_application(); \
00084       }
00085   #elif defined(_AFXDLL)
00086 
00087     #define HOOPLE_MAIN(obj_name, obj_args)  \
00088       HOOPLE_STARTUP_CODE; \
00089       SET_ARGC_ARGV(__argc, __argv); \
00090       tiny_application<obj_name> theApp;
00091   #elif defined(__WIN32__)
00092 
00093     #define HOOPLE_MAIN(obj_name, obj_args)  \
00094       HOOPLE_STARTUP_CODE; \
00095       int WINAPI WinMain(application_instance instance, \
00096           application_instance prev_instance, LPSTR lpCmdLine, \
00097           int nCmdShow) { \
00098         SET_ARGC_ARGV(__argc, __argv); \
00099         SET_INSTANCE_HANDLE(instance); \
00100         SETUP_FILE_LOGGER; \
00101         obj_name to_run_obj obj_args; \
00102         return to_run_obj.execute_application(); \
00103       }
00104   #endif
00105 
00107 
00108 #else  // not __UNIX__ or __WIN32__
00109 
00110   #define HOOPLE_MAIN(obj_name, obj_args)  \
00111     HOOPLE_STARTUP_CODE; \
00112     int main(int argc, char *argv[]) { \
00113       SETUP_CONSOLE_LOGGER; \
00114       obj_name to_run_obj obj_args; \
00115       return to_run_obj.execute_application(); \
00116     }
00117 #endif
00118 
00119 } //namespace.
00120 
00121 #endif // outer guard.
00122 
Generated on Sat Jan 28 04:22:08 2012 for hoople2 project by  doxygen 1.6.3