#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0

    Question Designing a Plugin Architecture for apps


    hi all...

    just wondering if anyone has experience in desiging a plugin architecture for applications and is willing to tell me the best way to go about it?

    cheers and thanks in advance
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    12
    Rep Power
    0
    Do specify what you mean by plugin. Do you mean software pluigins, in that case you need to define a common interface that the plug ins will use and a facility for using the plugins.

    For example, let's say you want initialization plugins for you widget. (Assuming C++)

    Code:
    class PluginContext
    {
      // Some data that plugins will need passes by main application
    };
    
    class WidgetPluginInterface
    {
    public:
      virtual WidgetPluginInterface() {}
      virtual ~WidgetPluginInterface() {}
      virtual public int initialize(PluginContext &context) = 0;
    };
    In your .dll/.so
    Code:
    class WidgetPlugin_1: public WigdetPluginInterface
    {
      virtual public int initialize(PluginContext &context)
      {
        // Do stuff with context if needed
        
        return 0;
      }
    }
    
    
    // Insert you favorite DLL/SO export tokens in this function (such as __dllspec, __export et al)
    WidgetInterface *createWidget()
    {
    	return new WidgetPlugin_1;
    }

    Now somewhere in your code:

    Code:
    // Read in config file and see which plugins to load
    
    // Load plugin via LoadLibrary or similar function (each plugin can be .dll/.so depending on design)
    
    // Call createWidget for each .dll/.so and then call initialize() with a context

    This is as generic as I can get without knowing the problem at hand.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0
    hi achacha...

    long story short, what i want to achieve is to develop an engine which can allow multiple developers to build their own 'tools', but be a part of an application framework...

    i have done something similar with a framework i developed under BCB6, but in that environment, i was able to make things a little more static...

    the engine doesn't actually need to know anything itself, all it needs to do is provide the conduit between the multiple tools...

    does this place the problem into a better context?

    cheers and thanks for the help so far

IMN logo majestic logo threadwatch logo seochat tools logo