Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common.h6
-rw-r--r--src/common/console.cc14
-rw-r--r--src/common/console.h2
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: