feisty meow concerns codebase 2.140
hoople_main.h
Go to the documentation of this file.
1#ifndef HOOPLE_MAIN_GROUP
2#define HOOPLE_MAIN_GROUP
3
4/*****************************************************************************\
5* *
6* Name : HOOPLE_MAIN group
7* Author : Chris Koeritz
8* *
9*******************************************************************************
10* Copyright (c) 2000-$now By Author. This program is free software; you can *
11* redistribute it and/or modify it under the terms of the GNU General Public *
12* License as published by the Free Software Foundation; either version 2 of *
13* the License or (at your option) any later version. This is online at: *
14* http://www.fsf.org/copyleft/gpl.html *
15* Please send any updates to: fred@gruntose.com *
16\*****************************************************************************/
17
19
20#include "application_shell.h"
21#include "command_line.h"
22#include "windoze_helper.h"
23
24#include <basis/contracts.h>
29
30namespace application {
31
32// The following versions of main programs are provided for different operating
33// systems and compilation environments. These support the requirements of the
34// HOOPLE startup code and program-wide features, assuming an object derived
35// from base_application is available.
36// The object derived from base_application must be provided in "obj_name".
37// The "obj_args" are any arguments that need to be passed to the object's
38// constructor; this list can be empty.
39// Note that the default logger used for unix and console mode win32 programs
40// is the console logger; that can be changed in the startup code for the
41// "obj_name".
42
43#define HOOPLE_STARTUP_CODE \
44 DEFINE_INSTANCE_HANDLE;
45
46#ifdef __WXWIDGETS__
48 #define HOOPLE_MAIN(obj_name, obj_args) \
49 HOOPLE_STARTUP_CODE; \
50 int main(int argc, char *argv[]) { \
51 SET_ARGC_ARGV(argc, argv); \
52 SETUP_COMBO_LOGGER; \
53 obj_name to_run_obj obj_args; \
54 return to_run_obj.execute_application(); \
55 }
56
58
59#elif defined(__UNIX__) || defined(__GNU_WINDOWS__)
61 #define HOOPLE_MAIN(obj_name, obj_args) \
62 HOOPLE_STARTUP_CODE; \
63 int main(int argc, char *argv[]) { \
64 SET_ARGC_ARGV(argc, argv); \
65 SETUP_COMBO_LOGGER; \
66 obj_name to_run_obj obj_args; \
67 return to_run_obj.execute_application(); \
68 }
69
71
72/*
73 * deprecated.
74#elif defined(_MSC_VER)
75 // for win32 we need to support four different environments--console mode,
76 // borland compilation, MFC programs and regular windows programs.
77 #ifdef _CONSOLE
79 #define HOOPLE_MAIN(obj_name, obj_args) \
80 HOOPLE_STARTUP_CODE; \
81 int main(int argc, char *argv[]) { \
82 SET_ARGC_ARGV(argc, argv); \
83 SETUP_COMBO_LOGGER; \
84 obj_name to_run_obj obj_args; \
85 return to_run_obj.execute_application(); \
86 }
87 #elif defined(_AFXDLL)
89 #define HOOPLE_MAIN(obj_name, obj_args) \
90 HOOPLE_STARTUP_CODE; \
91 SET_ARGC_ARGV(__argc, __argv); \
92 tiny_application<obj_name> theApp;
93 #elif defined(__WIN32__)
95 #define HOOPLE_MAIN(obj_name, obj_args) \
96 HOOPLE_STARTUP_CODE; \
97 int WINAPI WinMain(application_instance instance, \
98 application_instance prev_instance, LPSTR lpCmdLine, \
99 int nCmdShow) { \
100 SET_ARGC_ARGV(__argc, __argv); \
101 SET_INSTANCE_HANDLE(instance); \
102 SETUP_FILE_LOGGER; \
103 obj_name to_run_obj obj_args; \
104 return to_run_obj.execute_application(); \
105 }
106 #endif
107*/
108
110
111#else // not __UNIX__ or __WIN32__
113 #define HOOPLE_MAIN(obj_name, obj_args) \
114 HOOPLE_STARTUP_CODE; \
115 int main(int argc, char *argv[]) { \
116 SETUP_CONSOLE_LOGGER; \
117 obj_name to_run_obj obj_args; \
118 return to_run_obj.execute_application(); \
119 }
120#endif
121
122} //namespace.
123
124#endif // outer guard.
125
Implements an application lock to ensure only one is running at once.
Aids in achievement of platform independence.