diff options
author | David Corrales | 2007-05-12 20:00:52 +0000 |
---|---|---|
committer | David Corrales | 2007-05-12 20:00:52 +0000 |
commit | d1f56d93f934150f4b579c2e90564e2bf035f113 (patch) | |
tree | 09aae1d4077c8e1c933fdca88d34d890a46f8a6a /backends | |
parent | 86324f00bc561c03b281170125ef2fde14cae132 (diff) | |
download | scummvm-rg350-d1f56d93f934150f4b579c2e90564e2bf035f113.tar.gz scummvm-rg350-d1f56d93f934150f4b579c2e90564e2bf035f113.tar.bz2 scummvm-rg350-d1f56d93f934150f4b579c2e90564e2bf035f113.zip |
Use common/singleton.h in the concrete fs factories.
svn-id: r26814
Diffstat (limited to 'backends')
23 files changed, 45 insertions, 198 deletions
diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.cpp b/backends/fs/amigaos4/amigaos4-fs-factory.cpp index abb0790c18..becbd49003 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.cpp +++ b/backends/fs/amigaos4/amigaos4-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/amigaos4/amigaos4-fs-factory.h" #include "backends/fs/amigaos4/amigaos4-fs.cpp" -AmigaOSFilesystemFactory *AmigaOSFilesystemFactory::_instance = 0; - -AmigaOSFilesystemFactory *AmigaOSFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new AmigaOSFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(AmigaOSFilesystemFactory); AbstractFilesystemNode *AmigaOSFilesystemFactory::makeRootFileNode() const { return new AmigaOSFilesystemNode(); diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.h b/backends/fs/amigaos4/amigaos4-fs-factory.h index 4b34cc1954..861f28b794 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.h +++ b/backends/fs/amigaos4/amigaos4-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class AmigaOSFilesystemFactory : public AbstractFilesystemFactory { +class AmigaOSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<AmigaOSFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of AmigaOSFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of AmigaOSFilesytemFactory. - */ - static AmigaOSFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: AmigaOSFilesystemFactory() {}; private: - static AmigaOSFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*AMIGAOS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/dc/ronincd-fs-factory.cpp b/backends/fs/dc/ronincd-fs-factory.cpp index 92b2c5f7bb..0229a44c45 100644 --- a/backends/fs/dc/ronincd-fs-factory.cpp +++ b/backends/fs/dc/ronincd-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/dc/ronincd-fs-factory.h" #include "backends/fs/dc/dc-fs.cpp" -RoninCDFilesystemFactory *RoninCDFilesystemFactory::_instance = 0; - -RoninCDFilesystemFactory *RoninCDFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new RoninCDFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(RoninCDFilesystemFactory); AbstractFilesystemNode *RoninCDFilesystemFactory::makeRootFileNode() const { return new RoninCDFilesystemNode(); diff --git a/backends/fs/dc/ronincd-fs-factory.h b/backends/fs/dc/ronincd-fs-factory.h index 02cfe66c82..12590e8fa4 100644 --- a/backends/fs/dc/ronincd-fs-factory.h +++ b/backends/fs/dc/ronincd-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class RoninCDFilesystemFactory : public AbstractFilesystemFactory { +class RoninCDFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<RoninCDFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of RoninCDFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of RoninCDFilesytemFactory. - */ - static RoninCDFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: RoninCDFilesystemFactory() {}; private: - static RoninCDFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*RONINCD_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp index 1855fbc40d..7e64b37411 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/fs/ds/ds-fs-factory.cpp @@ -2,14 +2,7 @@ #include "backends/fs/ds/ds-fs.cpp" #include "dsmain.h" //for the isGBAMPAvailable() function -DSFilesystemFactory *DSFilesystemFactory::_instance = 0; - -DSFilesystemFactory *DSFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new DSFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(DSFilesystemFactory); AbstractFilesystemNode *DSFilesystemFactory::makeRootFileNode() const { if (DS::isGBAMPAvailable()) { diff --git a/backends/fs/ds/ds-fs-factory.h b/backends/fs/ds/ds-fs-factory.h index 5e96edc390..5bc847a7b2 100644 --- a/backends/fs/ds/ds-fs-factory.h +++ b/backends/fs/ds/ds-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class DSFilesystemFactory : public AbstractFilesystemFactory { +class DSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<DSFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of DSFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of DSFilesytemFactory. - */ - static DSFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: DSFilesystemFactory() {}; private: - static DSFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*DS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/fs-factory-maker.cpp b/backends/fs/fs-factory-maker.cpp index 636a39b5e3..bae3d1a30a 100644 --- a/backends/fs/fs-factory-maker.cpp +++ b/backends/fs/fs-factory-maker.cpp @@ -68,46 +68,46 @@ protected: AbstractFilesystemFactory *FilesystemFactoryMaker::makeFactory(){ #if defined(__amigaos4__) - return AmigaOSFilesystemFactory::instance(); + return &AmigaOSFilesystemFactory::instance(); #endif #if defined(__DC__) - return RoninCDFilesystemFactory::instance(); + return &RoninCDFilesystemFactory::instance(); #endif #if defined(__DS__) - return DSFilesystemFactory::instance(); + return &DSFilesystemFactory::instance(); #endif #if defined(__GP32__) - return GP32FilesystemFactory::instance(); + return &GP32FilesystemFactory::instance(); #endif #if defined(__MORPHOS__) - return ABoxFilesystemFactory::instance(); + return &ABoxFilesystemFactory::instance(); #endif #if defined(PALMOS_MODE) - return PalmOSFilesystemFactory::instance(); + return &PalmOSFilesystemFactory::instance(); #endif #if defined(__PLAYSTATION2__) - return Ps2FilesystemFactory::instance(); + return &Ps2FilesystemFactory::instance(); #endif #if defined(__PSP__) - return PSPFilesystemFactory::instance(); + return &PSPFilesystemFactory::instance(); #endif #if defined(__SYMBIAN32__) - return SymbianFilesystemFactory::instance(); + return &SymbianFilesystemFactory::instance(); #endif #if defined(UNIX) - return POSIXFilesystemFactory::instance(); + return &POSIXFilesystemFactory::instance(); #endif #if defined(WIN32) - return WindowsFilesystemFactory::instance(); + return &WindowsFilesystemFactory::instance(); #endif } diff --git a/backends/fs/gp32/gp32-fs-factory.cpp b/backends/fs/gp32/gp32-fs-factory.cpp index fc19bdf1cf..6328836c0e 100644 --- a/backends/fs/gp32/gp32-fs-factory.cpp +++ b/backends/fs/gp32/gp32-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/gp32/gp32-fs-factory.h" #include "backends/fs/gp32/gp32-fs.cpp" -GP32FilesystemFactory *GP32FilesystemFactory::_instance = 0; - -GP32FilesystemFactory *GP32FilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new GP32FilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(GP32FilesystemFactory); AbstractFilesystemNode *GP32FilesystemFactory::makeRootFileNode() const { return new GP32FilesystemNode(); diff --git a/backends/fs/gp32/gp32-fs-factory.h b/backends/fs/gp32/gp32-fs-factory.h index 1b34597d84..22c502d69f 100644 --- a/backends/fs/gp32/gp32-fs-factory.h +++ b/backends/fs/gp32/gp32-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class GP32FilesystemFactory : public AbstractFilesystemFactory { +class GP32FilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<GP32FilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of GP32FilesystemFactory using the Singleton pattern. - * - * @return A unique instance of GP32FilesytemFactory. - */ - static GP32FilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: GP32FilesystemFactory() {}; private: - static GP32FilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*GP32_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/morphos/abox-fs-factory.cpp b/backends/fs/morphos/abox-fs-factory.cpp index 4689a6a42f..9de810c361 100644 --- a/backends/fs/morphos/abox-fs-factory.cpp +++ b/backends/fs/morphos/abox-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/morphos/abox-fs-factory.h" #include "backends/fs/morphos/abox-fs.cpp" -ABoxFilesystemFactory *ABoxFilesystemFactory::_instance = 0; - -ABoxFilesystemFactory *ABoxFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new ABoxFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(ABoxFilesystemFactory); AbstractFilesystemNode *ABoxFilesystemFactory::makeRootFileNode() const { return new ABoxFilesystemNode(); diff --git a/backends/fs/morphos/abox-fs-factory.h b/backends/fs/morphos/abox-fs-factory.h index f6cf7774c5..b0d1dfb340 100644 --- a/backends/fs/morphos/abox-fs-factory.h +++ b/backends/fs/morphos/abox-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class ABoxFilesystemFactory : public AbstractFilesystemFactory { +class ABoxFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<ABoxFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of ABoxFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of ABoxFilesytemFactory. - */ - static ABoxFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: ABoxFilesystemFactory() {}; private: - static ABoxFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*ABOX_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/palmos/palmos-fs-factory.cpp b/backends/fs/palmos/palmos-fs-factory.cpp index 6be7021f77..1b0db0f042 100644 --- a/backends/fs/palmos/palmos-fs-factory.cpp +++ b/backends/fs/palmos/palmos-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/palmos/palmos-fs-factory.h" #include "backends/fs/palmos/palmos-fs.cpp" -PalmOSFilesystemFactory *PalmOSFilesystemFactory::_instance = 0; - -PalmOSFilesystemFactory *PalmOSFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new PalmOSFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(PalmOSFilesystemFactory); AbstractFilesystemNode *PalmOSFilesystemFactory::makeRootFileNode() const { return new PalmOSFilesystemNode(); diff --git a/backends/fs/palmos/palmos-fs-factory.h b/backends/fs/palmos/palmos-fs-factory.h index 618a1965d9..4bb94ab4c1 100644 --- a/backends/fs/palmos/palmos-fs-factory.h +++ b/backends/fs/palmos/palmos-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class PalmOSFilesystemFactory : public AbstractFilesystemFactory { +class PalmOSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<PalmOSFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of PalmOSFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of PalmOSFilesytemFactory. - */ - static PalmOSFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: PalmOSFilesystemFactory() {}; private: - static PalmOSFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*PALMOS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index b302bb31e8..bed3dc5f8f 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.cpp" -POSIXFilesystemFactory *POSIXFilesystemFactory::_instance = 0; - -POSIXFilesystemFactory *POSIXFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new POSIXFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(POSIXFilesystemFactory); AbstractFilesystemNode *POSIXFilesystemFactory::makeRootFileNode() const { return new POSIXFilesystemNode(); diff --git a/backends/fs/posix/posix-fs-factory.h b/backends/fs/posix/posix-fs-factory.h index 5195491b95..93f0ac115b 100644 --- a/backends/fs/posix/posix-fs-factory.h +++ b/backends/fs/posix/posix-fs-factory.h @@ -1,6 +1,7 @@ #ifndef POSIX_FILESYSTEM_FACTORY_H #define POSIX_FILESYSTEM_FACTORY_H +#include "common/singleton.h" #include "backends/fs/abstract-fs-factory.h" /** @@ -8,16 +9,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class POSIXFilesystemFactory : public AbstractFilesystemFactory { +class POSIXFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<POSIXFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of POSIXFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of POSIXFilesytemFactory. - */ - static POSIXFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +21,7 @@ protected: POSIXFilesystemFactory() {}; private: - static POSIXFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*POSIX_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp index 726eb87c6f..5f10974501 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/fs/ps2/ps2-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/ps2/ps2-fs-factory.h" #include "backends/fs/ps2/ps2-fs.cpp" -Ps2FilesystemFactory *Ps2FilesystemFactory::_instance = 0; - -Ps2FilesystemFactory *Ps2FilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new Ps2FilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(Ps2FilesystemFactory); AbstractFilesystemNode *Ps2FilesystemFactory::makeRootFileNode() const { return new Ps2FilesystemNode(); diff --git a/backends/fs/ps2/ps2-fs-factory.h b/backends/fs/ps2/ps2-fs-factory.h index de7ada6ba3..2dceb5a6dc 100644 --- a/backends/fs/ps2/ps2-fs-factory.h +++ b/backends/fs/ps2/ps2-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class Ps2FilesystemFactory : public AbstractFilesystemFactory { +class Ps2FilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<Ps2FilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of Ps2FilesystemFactory using the Singleton pattern. - * - * @return A unique instance of Ps2FilesytemFactory. - */ - static Ps2FilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: Ps2FilesystemFactory() {}; private: - static Ps2FilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*PS2_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index 2a0307d3f4..6fc829baf1 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/psp/psp-fs-factory.h" #include "backends/fs/psp/psp_fs.cpp" -PSPFilesystemFactory *PSPFilesystemFactory::_instance = 0; - -PSPFilesystemFactory *PSPFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new PSPFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(PSPFilesystemFactory); AbstractFilesystemNode *PSPFilesystemFactory::makeRootFileNode() const { return new PSPFilesystemNode(); diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/fs/psp/psp-fs-factory.h index 05388fa697..e751afbe1a 100644 --- a/backends/fs/psp/psp-fs-factory.h +++ b/backends/fs/psp/psp-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class PSPFilesystemFactory : public AbstractFilesystemFactory { +class PSPFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<PSPFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of PSPFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of PSPFilesytemFactory. - */ - static PSPFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: PSPFilesystemFactory() {}; private: - static PSPFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*PSP_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/symbian/symbian-fs-factory.cpp b/backends/fs/symbian/symbian-fs-factory.cpp index f3eb552159..87b1f0f05d 100644 --- a/backends/fs/symbian/symbian-fs-factory.cpp +++ b/backends/fs/symbian/symbian-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/symbian/symbian-fs-factory.h" #include "backends/fs/symbian/symbian-fs.cpp" -SymbianFilesystemFactory *SymbianFilesystemFactory::_instance = 0; - -SymbianFilesystemFactory *SymbianFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new SymbianFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(SymbianFilesystemFactory); AbstractFilesystemNode *SymbianFilesystemFactory::makeRootFileNode() const { return new SymbianFilesystemNode(true); diff --git a/backends/fs/symbian/symbian-fs-factory.h b/backends/fs/symbian/symbian-fs-factory.h index 4bbac728cb..4acca7924c 100644 --- a/backends/fs/symbian/symbian-fs-factory.h +++ b/backends/fs/symbian/symbian-fs-factory.h @@ -8,16 +8,9 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class SymbianFilesystemFactory : public AbstractFilesystemFactory { +class SymbianFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<SymbianFilesystemFactory> { public: typedef Common::String String; - - /** - * Creates an instance of SymbianFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of SymbianFilesytemFactory. - */ - static SymbianFilesystemFactory *instance(); virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; @@ -27,7 +20,7 @@ protected: SymbianFilesystemFactory() {}; private: - static SymbianFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*SYMBIAN_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/windows/windows-fs-factory.cpp b/backends/fs/windows/windows-fs-factory.cpp index fb77b4ca07..76b62e5deb 100644 --- a/backends/fs/windows/windows-fs-factory.cpp +++ b/backends/fs/windows/windows-fs-factory.cpp @@ -1,14 +1,7 @@ #include "backends/fs/windows/windows-fs-factory.h" #include "backends/fs/windows/windows-fs.cpp" -WindowsFilesystemFactory *WindowsFilesystemFactory::_instance = 0; - -WindowsFilesystemFactory *WindowsFilesystemFactory::instance(){ - if(_instance == 0){ - _instance = new WindowsFilesystemFactory(); - } - return _instance; -} +DECLARE_SINGLETON(WindowsFilesystemFactory); AbstractFilesystemNode *WindowsFilesystemFactory::makeRootFileNode() const { return new WindowsFilesystemNode(); diff --git a/backends/fs/windows/windows-fs-factory.h b/backends/fs/windows/windows-fs-factory.h index a7abf390ae..b260eab65a 100644 --- a/backends/fs/windows/windows-fs-factory.h +++ b/backends/fs/windows/windows-fs-factory.h @@ -8,17 +8,10 @@ * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class WindowsFilesystemFactory : public AbstractFilesystemFactory { +class WindowsFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<WindowsFilesystemFactory> { public: typedef Common::String String; - /** - * Creates an instance of WindowsFilesystemFactory using the Singleton pattern. - * - * @return A unique instance of WindowsFilesytemFactory. - */ - static WindowsFilesystemFactory *instance(); - virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; @@ -27,7 +20,7 @@ protected: WindowsFilesystemFactory() {}; private: - static WindowsFilesystemFactory *_instance; + friend class Common::Singleton<SingletonBaseType>; }; #endif /*WINDOWS_FILESYSTEM_FACTORY_H*/ |