Ignore:
Timestamp:
05/04/12 13:12:31 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Improved plugincontainer (pr1).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/plugincontainer.h

    r5487 r5488  
    4141struct roar_plugincontainer; 
    4242 
     43struct roar_plugincontainer_callbacks { 
     44 /* prefree() is called before the container is freed. 
     45  */ 
     46 int (*prefree)(struct roar_plugincontainer * cont, void ** userdata); 
     47 
     48 /* freeuserdata() is called when the userdata needs to be freed. 
     49  * This is the case then the container is freed. 
     50  * It is not called when the current userdata is NULL. 
     51  * If not set or userdata is still non-NULL after this call the userdata 
     52  * is freed using roar_mm_free(). 
     53  */ 
     54 int (*freeuserdata)(struct roar_plugincontainer * cont, void ** userdata); 
     55 
     56 /* freecontext() is called when the context needs to be freed. 
     57  * It is not called when the current context is NULL. 
     58  * If not set or context is still non-NULL after this call the context 
     59  * is freed using roar_mm_free(). 
     60  */ 
     61 int (*freecontext)(struct roar_plugincontainer * cont, void ** context); 
     62 
     63 /* preload() and postload() are called before and after a plugin is loaded. 
     64  */ 
     65 int (*preload) (struct roar_plugincontainer * cont, void ** context, 
     66                 const char * name, int flags, struct roar_dl_librarypara * para); 
     67 int (*postload)(struct roar_plugincontainer * cont, void ** context, struct roar_dl_lhandle * lhandle, 
     68                 const char * name, int flags, struct roar_dl_librarypara * para); 
     69 
     70 /* preunload() and postunload() are called before and after a plugin is unloaded. 
     71  * Those functions are also called if the plugin was loaded but ra_init was not yet done or failed. 
     72  */ 
     73 int (*preunload) (struct roar_plugincontainer * cont, void ** context, struct roar_dl_lhandle * lhandle); 
     74 int (*postunload)(struct roar_plugincontainer * cont, void ** context); 
     75 
     76 /* prera_init() and postra_init() are called before and after a plugin is ra_init-ed. 
     77  * This is also true if the plugin is ra_init-ed while being loaded. 
     78  * Note the limits of roar_plugincontainer_ra_init() if this is used 
     79  * with roar_plugincontainer_ra_init(). 
     80  * postra_init() is also called in case the ra_init failed. 
     81  */ 
     82 int (*prera_init) (struct roar_plugincontainer * cont, void ** context, struct roar_dl_lhandle * lhandle, 
     83                    struct roar_dl_librarypara * para); 
     84 int (*postra_init)(struct roar_plugincontainer * cont, void ** context, struct roar_dl_lhandle * lhandle, 
     85                    struct roar_dl_librarypara * para); 
     86}; 
     87 
     88struct roar_plugincontainer_plugininfo { 
     89 /* The name of the plugin. 
     90  */ 
     91 const char * libname; 
     92 /* The roardl's library handle. 
     93  */ 
     94 struct roar_dl_lhandle * handle; 
     95 /* The number of librarys/plugins depending on this plugin. 
     96  */ 
     97 size_t rdepends; 
     98 /* A pointer to the current user context. 
     99  */ 
     100 void ** context; 
     101}; 
     102 
    43103/* Create a new plugin container. 
    44104 * Takes a default parameter set. 
     
    58118int roar_plugincontainer_unref(struct roar_plugincontainer * cont); 
    59119 
    60 /* Get a lhandle by name of the loaded plugin 
     120/* Set callbacks. 
     121 */ 
     122int roar_plugincontainer_set_callbacks(struct roar_plugincontainer * cont, 
     123                                       const struct roar_plugincontainer_callbacks * callbacks); 
     124 
     125/* Set container's userdata. 
     126 */ 
     127int roar_plugincontainer_set_userdata(struct roar_plugincontainer * cont, void * userdata); 
     128 
     129/* Get container's userdata. 
     130 */ 
     131void * roar_plugincontainer_get_userdata(struct roar_plugincontainer * cont); 
     132 
     133/* Get a lhandle by name of the loaded plugin. 
    61134 */ 
    62135struct roar_dl_lhandle * roar_plugincontainer_get_lhandle_by_name (struct roar_plugincontainer * cont, 
    63136                                                                   const char * name); 
     137 
     138/* Get infos about current state of plugin. 
     139 */ 
     140struct roar_plugincontainer_plugininfo roar_plugincontainer_get_info_by_name (struct roar_plugincontainer * cont, 
     141                                                                              const char * name); 
    64142 
    65143// plugin loading and unloading: 
Note: See TracChangeset for help on using the changeset viewer.