00001 #ifndef APPLICATION_BASE_CLASS
00002 #define APPLICATION_BASE_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00025 #include "opsysdll.h"
00026
00027 #include <basis/object_base.h>
00028 #include <data_struct/static_memory_gremlin.h>
00029
00030
00031 #include <loggers/file_logger.h>
00032
00033 class OPSYSTEM_CLASS_STYLE application_base
00034 : public virtual object_base
00035 {
00036 public:
00037 virtual ~application_base();
00038 virtual int execute() = 0;
00040
00044 };
00045
00047
00048 #if 0
00049
00051
00058 class example_app_base : public application_base
00059 {
00060 public:
00061 example_app_base() : application_base(static_class_name()) {}
00063
00064 IMPLEMENT_CLASS_NAME("example_app_base");
00066
00067 int execute() { }
00068 };
00069
00071
00072 int __example__main(int argc, char *argv[])
00073 {
00074 example_app_base root_program;
00075 return root_program.execute();
00076 }
00077
00079
00080 int WINAPI __example__WinMain(application_instance instance,
00081 application_instance prev_instance, LPSTR lpCmdLine, int nCmdShow)
00082 {
00083 example_app_base root_program;
00084 return root_program.execute();
00085 }
00086
00088
00094 class mfc_example_app_base : public tiny_shell
00095 {
00096 public:
00097 mfc_example_app_base();
00098 int execute() {}
00099 };
00100
00102
00112 HOOPLE_MAIN(example_app_base, (P, D, Q))
00113
00114
00115 HOOPLE_MAIN(example_app_base, )
00116
00117 #endif // example guard.
00118
00120
00122
00126 #ifdef __UNIX__
00127 #define SET_ARGC_ARGV(argc, argv) { \
00128 __argc = argc; \
00129 __argv = argv; \
00130 }
00131 #else
00132 #define SET_ARGC_ARGV(argc, argv) {}
00133
00134 #endif
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 #ifdef __WXWIDGETS__
00149 //where'd this go? IMPLEMENT_APP(obj_name);
00150
00151 #define HOOPLE_MAIN(obj_name, obj_args) \
00152 HOOPLE_STARTUP_CODE; \
00153 int main(int argc, char *argv[]) { \
00154 SET_ARGC_ARGV(argc, argv); \
00155 SET_DEFAULT_COMBO_LOGGER; \
00156 obj_name root_object obj_args; \
00157 return root_object.execute(); \
00158 }
00159
00160 #elif defined(__UNIX__)
00162 #define HOOPLE_MAIN(obj_name, obj_args) \
00163 HOOPLE_STARTUP_CODE; \
00164 int main(int argc, char *argv[]) { \
00165 SET_ARGC_ARGV(argc, argv); \
00166 SET_DEFAULT_COMBO_LOGGER; \
00167 obj_name root_object obj_args; \
00168 return root_object.execute(); \
00169 }
00170 #elif defined(__WIN32__)
00171
00172
00173 #ifdef _CONSOLE
00175 #define HOOPLE_MAIN(obj_name, obj_args) \
00176 HOOPLE_STARTUP_CODE; \
00177 int main(int argc, char *argv[]) { \
00178 SET_DEFAULT_COMBO_LOGGER; \
00179 obj_name root_object obj_args; \
00180 return root_object.execute(); \
00181 }
00182 #elif defined(_AFXDLL)
00184 #define HOOPLE_MAIN(obj_name, obj_args) \
00185 HOOPLE_STARTUP_CODE; \
00186 tiny_application<obj_name> theApp;
00187 #elif defined(__WIN32__)
00189 #define HOOPLE_MAIN(obj_name, obj_args) \
00190 HOOPLE_STARTUP_CODE; \
00191 int WINAPI WinMain(application_instance instance, \
00192 application_instance prev_instance, LPSTR lpCmdLine, \
00193 int nCmdShow) { \
00194 SET_INSTANCE_HANDLE(instance); \
00195 SET_DEFAULT_FILE_LOGGER; \
00196 obj_name root_object obj_args; \
00197 return root_object.execute(); \
00198 }
00199 #endif
00200 #else // not __UNIX__ or __WIN32__
00202 #define HOOPLE_MAIN(obj_name, obj_args) \
00203 HOOPLE_STARTUP_CODE; \
00204 int main(int argc, char *argv[]) { \
00205 SET_DEFAULT_CONSOLE_LOGGER; \
00206 obj_name root_object obj_args; \
00207 return root_object.execute(); \
00208 }
00209 #endif
00210
00211 #endif // outer guard.
00212