diff options
author | Max Horn | 2010-10-19 09:43:53 +0000 |
---|---|---|
committer | Max Horn | 2010-10-19 09:43:53 +0000 |
commit | ddf0a3d80c726dfb274473c1931b184a46493e1d (patch) | |
tree | ff807d21df273470e9cc4503d4c3daaa1a6d3f91 /engines/sword25 | |
parent | 88bca8e13d0d385161bd8aee95998345a6aa516e (diff) | |
download | scummvm-rg350-ddf0a3d80c726dfb274473c1931b184a46493e1d.tar.gz scummvm-rg350-ddf0a3d80c726dfb274473c1931b184a46493e1d.tar.bz2 scummvm-rg350-ddf0a3d80c726dfb274473c1931b184a46493e1d.zip |
SWORD25: Move BS_ServiceInfo to service_ids.h and turn it into a POD struct
svn-id: r53607
Diffstat (limited to 'engines/sword25')
-rw-r--r-- | engines/sword25/kernel/kernel.cpp | 9 | ||||
-rw-r--r-- | engines/sword25/kernel/kernel.h | 18 | ||||
-rw-r--r-- | engines/sword25/kernel/service_ids.h | 33 |
3 files changed, 25 insertions, 35 deletions
diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 78181bc4d3..8215a95bf6 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -49,6 +49,7 @@ namespace Sword25 { #define BS_LOG_PREFIX "KERNEL" + Kernel *Kernel::_Instance = 0; Kernel::Kernel() : @@ -61,7 +62,7 @@ Kernel::Kernel() : BS_LOGLN("created."); // Read the BS_SERVICE_TABLE and prepare kernel structures - for (uint i = 0; i < BS_SERVICE_COUNT; i++) { + for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) { // Is the superclass already registered? Superclass *pCurSuperclass = NULL; Common::Array<Superclass *>::iterator Iter; @@ -136,7 +137,7 @@ Kernel::Superclass::Superclass(Kernel *pKernel, const Common::String &Identifier _Identifier(Identifier), _ServiceCount(0), _ActiveService(NULL) { - for (uint i = 0; i < BS_SERVICE_COUNT; i++) + for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) _ServiceCount++; } @@ -158,7 +159,7 @@ Common::String Kernel::Superclass::GetServiceIdentifier(uint Number) { if (Number > _ServiceCount) return NULL; uint CurServiceOrd = 0; - for (uint i = 0; i < BS_SERVICE_COUNT; i++) { + for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) { if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) { if (Number == CurServiceOrd) return BS_SERVICE_TABLE[i].ServiceIdentifier; @@ -180,7 +181,7 @@ Common::String Kernel::Superclass::GetServiceIdentifier(uint Number) { * For the superclass "sfx" an example could be "Fmod" or "directsound" */ Service *Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) { - for (uint i = 0; i < BS_SERVICE_COUNT; i++) + for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier && BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) { Service *NewService_ = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); diff --git a/engines/sword25/kernel/kernel.h b/engines/sword25/kernel/kernel.h index 9a115db908..a2bbab9f6f 100644 --- a/engines/sword25/kernel/kernel.h +++ b/engines/sword25/kernel/kernel.h @@ -331,24 +331,6 @@ private: bool _RegisterScriptBindings(); }; -/** - * This is only a small class that manages the data of a service. It is a little ugly, I know, - * but with Common::String a simple struct could not be used. - */ -class BS_ServiceInfo { -public: - BS_ServiceInfo(const Common::String &SuperclassIdentifier_, const Common::String &ServiceIdentifier_, - Service*(*CreateMethod_)(Kernel *)) { - this->SuperclassIdentifier = SuperclassIdentifier_; - this->ServiceIdentifier = ServiceIdentifier_; - this->CreateMethod = CreateMethod_; - } - - Common::String SuperclassIdentifier; - Common::String ServiceIdentifier; - Service*(*CreateMethod)(Kernel *); -}; - } // End of namespace Sword25 #endif diff --git a/engines/sword25/kernel/service_ids.h b/engines/sword25/kernel/service_ids.h index 0e907155bf..4f217cf175 100644 --- a/engines/sword25/kernel/service_ids.h +++ b/engines/sword25/kernel/service_ids.h @@ -61,23 +61,30 @@ Service *OggTheora_CreateObject(Kernel *pKernel); Service *OggTheora_CreateObject(Kernel *pKernel) { return NULL; } #endif + +/** + * This is only a small struct that manages the data of a service. + */ +struct BS_ServiceInfo { + const char *SuperclassIdentifier; + const char *ServiceIdentifier; + Service *(*CreateMethod)(Kernel *); +}; + // Services are recorded in this table const BS_ServiceInfo BS_SERVICE_TABLE[] = { - // The first two parameters are the name of the superclass and service - // The third parameter is the static method of the class that creates an object - // of the class and returns it - // Example: - // BS_ServiceInfo("Superclass", "Service", CreateMethod) - BS_ServiceInfo("gfx", "opengl", GraphicEngine_CreateObject), - BS_ServiceInfo("package", "archiveFS", PackageManager_CreateObject), - BS_ServiceInfo("input", "winapi", InputEngine_CreateObject), - BS_ServiceInfo("sfx", "fmodex", SoundEngine_CreateObject), - BS_ServiceInfo("script", "lua", LuaScriptEngine_CreateObject), - BS_ServiceInfo("geometry", "std", Geometry_CreateObject), - BS_ServiceInfo("fmv", "oggtheora", OggTheora_CreateObject), + // The first two values are the name of the superclass and service. + // The third value is the static method of the class that creates an object + // of the class and returns it. + { "gfx", "opengl", GraphicEngine_CreateObject }, + { "package", "archiveFS", PackageManager_CreateObject }, + { "input", "winapi", InputEngine_CreateObject }, + { "sfx", "fmodex", SoundEngine_CreateObject }, + { "script", "lua", LuaScriptEngine_CreateObject }, + { "geometry", "std", Geometry_CreateObject }, + { "fmv", "oggtheora", OggTheora_CreateObject } }; -const uint BS_SERVICE_COUNT = sizeof(BS_SERVICE_TABLE) / sizeof(BS_ServiceInfo); } // End of namespace Sword25 |