mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-06 19:08:15 +00:00
SWORD25: Move BS_ServiceInfo to service_ids.h and turn it into a POD struct
svn-id: r53607
This commit is contained in:
parent
88bca8e13d
commit
ddf0a3d80c
@ -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);
|
||||
|
@ -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
|
||||
|
@ -61,23 +61,30 @@ Service *OggTheora_CreateObject(Kernel *pKernel);
|
||||
Service *OggTheora_CreateObject(Kernel *pKernel) { return NULL; }
|
||||
#endif
|
||||
|
||||
// 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),
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user