each plugin is a DLL file, we can dump it by dumpbin.exe, this is the result:
Dump of file foo_xxx.dll
File Type: DLL
Section contains the following exports for foo_xxx.dll
0 characteristics
40A189FA time date stamp Wed May 12 10:20:42 2004
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00009AF8 foobar2000_get_interface
and in component_client.cpp
extern "C"
{
__declspec(dllexport) foobar2000_client * _cdecl foobar2000_get_interface(foobar2000_api * p_api,HINSTANCE hIns)
{
#ifdef _DEBUG
selftest();
#endif
cfg_var::config_on_app_init();
g_hIns = hIns;
g_api = p_api;
return &g_client;
}
}
so, "foobar2000_get_interface" is the unique interface between plugin and the foobar client (core). foosion also has told me about this,
how does foobar_client get foobar_client point via foobar2000_get_interface,
example, we can get foobar2000_get_interface this way (I'm not very sure about these codes, just my test codes, ):
typedef foobar2000_client* (*get_interface)(foobar2000_api* p_api , HINSTANCE hinst );
int main(int argc, char* argv[])
{
HINSTANCE h_xxx;
get_interface my_fb_getinterface;
h_xxx=LoadLibrary(
"F:\\FOO_SDK\\foobar2000\\foo_xxx\\Release\\foo_xxx.dll" // file name of module
);
if (NULL == h_xxx)
return 0;
my_fb_getinterface = (get_interface)GetProcAddress(h_xxx, "foobar2000_get_interface");
FreeLibrary(h_xxx);
return 1;
}
we knew that:
in foobar2000 SDK, foobar2000_api is a pure interface, like this:
class NOVTABLE foobar2000_api
{
...
}
shall I derive a class from it and instance it?
the function params are :
foobar2000_client* my_fb_getinterface(foobar2000_api* p_api , HINSTANCE hinst )
if I want to get the pointer of foobar2000_client, how to invoke the interface "foobar2000_get_interface" ?
Is foobar2000_client a pointer to core?
AND, after get the pointer of foobar2000_client,
we can see each plugin's soucecode, it must have these declaration:
static service_factory_single_t<menu_item,components_menu_item_xxx> foo1;
static service_factory_single_t<componentversion,version_xxx> foo2;
...
in service.cpp
service_base * service_factory_base::enum_create(const GUID &g,int n)
{
assert(core_api::are_services_available());
return g_api->service_enum_create(g,n);
}
seems that we can create a service via g_api and a GUID.
Could Anyone show me the example sourcecode in foobar client?
just about:
1. get a pointer to plugin, communicated with the plugin
2. create an "unkown" object (derived from a common service, but implemented in a plugin's sourcecode)
3. organize the service object, some for GUI, like menu, user interface; and some for preference dialog, and so on , you should have known that so many classes derived from "service_base", you can show me 2 or more examples, thanks!
if you want to reply this post, explain clearly, please! you know, I'm studying "Design Patterns" (by GoF), what a mess in my brain
I want to get some examples and application about" Design Patterns", obviously , foobar is a good concrete model.
Serious PS: I am just interested in the Design Patterns of foobar2000, not hacking it.
Last: forgiving me the poor English.... , but I think you can read my mind, if you really good at Design Pattern & foobar2000.