Help - Search - Members - Calendar
Full Version: Dynamically instantiating things that would be normally created using
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
Quiark
Hi, I'm trying to create a .NET binding to be able to write my component in .NET. I want the binding to be general to allow easy writing of other components (we'll see how far I will get).

The problem is that I need to create preferences_page and other objects dynamically and so can't use the normal
CODE
static preferences_page_factory_t<CTestPrefPage> testPrefPage;

construct, because I don't know what pref pages the .NET components will have in advance. This also applies to mainmenu_commands_factory_t and others.

So is there any other way to create the objects than using a static factory ? I've tried
CODE

    class PageWrapper {
    public:
        preferences_page_factory_t<CCustomPrefPage> testPrefPage;
    };

and then
        PageWrapper *p = new PageWrapper();

but that fails, because it needs to be done before all services are available (as I understood from the assert).

Thank you for any answers
foosion
You cannot create service factories after the component is initialised. Every service factory you are going to use has to be created before foobar2000_client::get_service_list() returns, and has to exist until the component is unloaded. If you are going that way, you will have to replace the standard version of foobar2000_component_client with your own implementation.
Quiark
Thanks, I'll try it this way.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.