implementing plugin types with a common base type



Hi. I am developing a glib/gobject application that makes use of GTypeModule to load plugins that register service types with GType. I would like to derive these service types from a common gobject type. The question I have is where to define that common base type. I notice that this base type cannot be defined statically in the body of the main application, since any dynamic type whose ancestor is a static type causes errors when GTypeModule reloads the plugin, i.e. any static ancestor in the class heirarchy demands that the type plugin must stay loaded -- defeating the
whole benefit of loading/unloading types as needed.

So, the next logical step might be to define the base type as a dynamic type (plugin) itself. That's fine, but it raises questions such as: who should load this base type? Should the base type be registered (as a dynamic type) by the main application before it loads the plugins that implement types that derive from it? Or, should the plugins each be
responsible for loading any base types they require?

If the main application registers the base type, then it must delivery the type_id to the plugin (this would be do-able in the plugins initialize() function -- or, the plugin could try to grab the base type by name in its type registration call.) The second alternative of having the plugins themselves register the dynamic base type seems to make sense
also.

I am seeking suggestions on the "preferred way" to implement this.

Phil




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]