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:
parent
c418282ec7
commit
74bf578bda
7 changed files with 37 additions and 34 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue