Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Dynamic Service Creation (Read 2227 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Dynamic Service Creation

I would like to add customized panels for my new foo_browser component.  Currently, I have a class call music_browser_generic which implements ui_extension::window, and I create four of these as static variables.

What I would like to do is to generate these at runtime inside of an initquit class or something similar so that I can make it possible to customize all the panels, but my initial attempts at this have been unsucessful.  The services code are great but they are a bit hairy even after reading the readme.

Currently all my panels are declared like this:

Code: [Select]
static service_factory_single_t<music_browser_generic> g_music_browser_genre( "Genre", "%genre%", guid_genre );


what I would like to do is something like this:

Code: [Select]
class music_browser_initquit : public initquit 
{
   music_browser_generic * m_genre;

  virtual void on_init()
  {
     m_genre = new service_impl_t<music_browser_generic>( "Genre", "%genre%", guid_genre );
  }

     virtual void on_quit()
     {
        delete m_genre;
     }
};
static initquit_factory_t< music_browser_initquit > g_initquit;


But I can't seem to figure this out.

Thanks
There used to be a link to my website here.

 

Dynamic Service Creation

Reply #1
Service factories need to created statically; they need to exist before the core retrieves the list of service factories. This is implemented in component client and called even before your configuration is loaded. The typical solution to this problem is to have a service type that can enumerate and spawn different "subservices"; the prime example for this is the menu services in the SDK. Perhaps the UI extension API can be extended in this direction.