Jump to content
  • Advertisement
Sign in to follow this  
haust

Pluggable factories and dll ??

This topic is 4931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, i've just read Timothy R. Culp's "Industrial Strength Pluggable Factories" article (http://www.adtmag.com/joop/crarticle.asp?ID=1520) and somewhere he talks about adding new object types by using plugins "These plug-in libraries are loaded at runtime (using dlopen for UNIX or LoadLibrary for Windows) to extend the shape hierarchy dynamically without modifying the Shape class". My question is how is this possible ?? As far as I understand it, the system is based on a template with a registry map where each new derived class is automatically added to this registry. The main requirement for this to work is that the registry map must be unique (use of static). Now if I want to create a new class in a separate dll, I will have another static registry which breaks the pattern. If someone can explain me what I didn't understood it would be cool :). haust.

Share this post


Link to post
Share on other sites
Advertisement
He doesn't really explain how to do it, but here's how i would handle the case:

If using a DLL you obviously can't use a static map as you found it will be a second instance inside the dll. Instead you export a RegisterPlugin function that accepts a generic factory container. The function will register the dlls factories in the passed container.

I'm using this for example for a image format loader manager which i pass to my abstract renderer inside a dll. So the main app decides which formats are available by registering them and the renderers just look inside the list (simplified).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!