few tool functions for the plugin implementation

* plugin_name() to figure out the name of the plugin
 * plugin_refinc() and plugin_refdec() to manage the refcount
This commit is contained in:
Christian Thaeter 2008-11-05 11:11:25 +01:00
parent c26cd391b0
commit 7afce647fb
2 changed files with 51 additions and 2 deletions

View file

@ -154,7 +154,8 @@ lumiera_plugin_error (LumieraPlugin self)
return self->error;
}
void *
void*
lumiera_plugin_handle (LumieraPlugin self)
{
REQUIRE (self);
@ -162,6 +163,27 @@ lumiera_plugin_handle (LumieraPlugin self)
}
const char*
lumiera_plugin_name (LumieraPlugin self)
{
return self?self->name:NULL;
}
void
lumiera_plugin_refinc (LumieraPlugin self)
{
++self->refcnt;
}
void
lumiera_plugin_refdec (LumieraPlugin self)
{
--self->refcnt;
}
int
lumiera_plugin_discover (LumieraPlugin (*callback_load)(const char* plugin),
int (*callback_register) (LumieraPlugin))
@ -370,7 +392,6 @@ lumiera_plugin_delete_fn (PSplaynode node)
ENSURE (!self->refcnt, "plugin %s still in use at shutdown", self->name);
const char* ext = strrchr (self->name, '.');
LumieraPlugintype itr = lumiera_plugin_types;

View file

@ -137,6 +137,34 @@ void*
lumiera_plugin_handle (LumieraPlugin self);
/**
* Query the plugin name
* The name is the path and filname under which it was loaded
* @param self plugin to query
* @return pointer to the name string
*/
const char*
lumiera_plugin_name (LumieraPlugin self);
/**
* Increment refcount
* @internal
* @param self plugin which refcount to increment
*/
void
lumiera_plugin_refinc (LumieraPlugin self);
/**
* Decrement refcount
* @internal
* @param self plugin which refcount to decrement
*/
void
lumiera_plugin_refdec (LumieraPlugin self);
/**
* Tries to unload a plugin.
* When the Plugin is unused, then all resources associated with it are freed and it will be removed from memory