diff options
author | Stijn Buys <ingar@osirion.org> | 2008-01-31 18:22:44 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-01-31 18:22:44 +0000 |
commit | f794b9ee52293cefd6ac73fdf0d2a01c5388f057 (patch) | |
tree | 2838d7ee11ae49e2e519ad604ba41f7071fb8288 /src/common | |
parent | 1ddff2045848da5136e9e8131e335ac7626b8f68 (diff) |
modular system works now
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/common.h | 6 | ||||
-rw-r--r-- | src/common/console.cc | 14 | ||||
-rw-r--r-- | src/common/console.h | 2 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/common/common.h b/src/common/common.h index c47b09f..1be6827 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -12,13 +12,13 @@ /// common functions and components that are used by the other subsytems namespace common { - // initialize common components + /// initialize common components void init(); - // shutdown common components + /// shutdown common components void shutdown(); -} // namespace common +} #include "common/console.h" diff --git a/src/common/console.cc b/src/common/console.cc index e4fd215..a7d0dd7 100644 --- a/src/common/console.cc +++ b/src/common/console.cc @@ -6,21 +6,29 @@ #include "common/console.h" -// TODO enforce singleton +#include <iostream> + +#include <stdlib.h> namespace common { Console *Console::console_instance = 0; Console::Console() { + if (console_instance) { + std::cerr << "duplicate common::Console::console_instance" << std::endl; + exit(2); + } console_instance = this; } -Console::~Console() { +Console::~Console() +{ console_instance = 0; } -Console *Console::instance() { +Console *Console::instance() +{ return console_instance; } diff --git a/src/common/console.h b/src/common/console.h index fbda5da..0706f11 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -45,7 +45,7 @@ public: /// stream to send debug messages too virtual std::ostream & debugstream() = 0; - /// a pointer to the current console implementation + /// a pointer to the current console instance static Console *instance(); private: |