1 /*****************************************************************************\
3 * Name : application_shell *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 2000-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "application_shell.h"
17 #include <basis/astring.h>
18 #include <basis/functions.h>
19 #include <configuration/application_configuration.h>
20 #include <loggers/combo_logger.h>
21 #include <loggers/program_wide_logger.h>
22 #include <timely/time_stamp.h>
31 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
33 using namespace basis;
34 using namespace configuration;
35 using namespace loggers;
36 using namespace mathematics;
37 using namespace textual;
38 using namespace timely;
40 namespace application {
42 const int MAXIMUM_COMMAND_LINE = 32 * KILOBYTE;
43 // maximum command line that we'll deal with here.
45 application_shell *not_so_hidden_pointer = NULL; // fodder for the single instance function.
47 application_shell *application_shell::single_instance() { return not_so_hidden_pointer; }
49 application_shell::application_shell()
51 c_exit_value(120) // if this is never changed from the default, that in itself is an error.
53 // we create a combo logger for program-wide usage.
55 not_so_hidden_pointer = this; // setup the single instance method.
58 application_shell::~application_shell()
60 if (not_so_hidden_pointer == this) not_so_hidden_pointer = NULL; // only scorch it when it's us.
63 outcome application_shell::log(const base_string &to_print, int filter)
65 outcome to_return = common::OKAY;
66 if (program_wide_logger::get().member(filter)) {
67 astring temp_log(to_print);
68 if (temp_log.length())
69 temp_log.insert(0, time_stamp::notarize(true));
70 to_return = program_wide_logger::get().log(temp_log, filter);
75 int application_shell::execute_application()
78 c_exit_value = execute();
79 } catch (const char *message) {
80 printf("caught exception:\n%s\n", message);
81 } catch (astring &message) {
82 printf("caught exception:\n%s\n", message.s());
84 printf("caught exception: unknown type!\n");