Changed the singleton code to allow for custom object factories; this allowed me to change OSystem to use the singleton base class, too

svn-id: r16404
This commit is contained in:
Max Horn 2005-01-01 19:19:06 +00:00
parent c418282ec7
commit 74bf578bda
7 changed files with 37 additions and 34 deletions

View file

@ -31,9 +31,10 @@
#include "common/config-manager.h"
#include "common/system.h"
static OSystem *s_system = 0;
DECLARE_SINGLETON(OSystem);
static OSystem *createSystem() {
template <>
OSystem *makeInstance<>() {
// Attention: Do not call parseGraphicsMode() here, nor any other function
// which needs to access the OSystem instance, else you get stuck in an
// endless loop.
@ -58,13 +59,6 @@ static OSystem *createSystem() {
#endif
}
OSystem &OSystem::instance() {
if (!s_system)
s_system = createSystem();
return *s_system;
}
bool OSystem::setGraphicsMode(const char *name) {
if (!name)
return false;