diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-01-30 22:36:18 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-01-30 22:36:18 +0000 |
commit | 45c86417cbac76159918e1429a391e2eb510bc32 (patch) | |
tree | 561b9a266c705580d5cb28ea6497b383eabdac1a | |
parent | 7e214c2b8977d5a19edf5f4ec6b059bd6ec9626d (diff) | |
download | libbu++-45c86417cbac76159918e1429a391e2eb510bc32.tar.gz libbu++-45c86417cbac76159918e1429a391e2eb510bc32.tar.bz2 libbu++-45c86417cbac76159918e1429a391e2eb510bc32.tar.xz libbu++-45c86417cbac76159918e1429a391e2eb510bc32.zip |
Added some more helpers to Plugger, which really needs to get with the times and
use Hash and exceptions.
-rw-r--r-- | src/plugger.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/plugger.h b/src/plugger.h index 4faca92..b531fae 100644 --- a/src/plugger.h +++ b/src/plugger.h | |||
@@ -115,7 +115,17 @@ public: | |||
115 | 115 | ||
116 | void registerExternalPlugin( const char *sFName, const char *sPluginName ) | 116 | void registerExternalPlugin( const char *sFName, const char *sPluginName ) |
117 | { | 117 | { |
118 | PluginReg *pReg = new PluginReg; | 118 | PluginReg *pReg = (PluginReg *)hPlugin[sPluginName]; |
119 | if( pReg != NULL ) | ||
120 | { | ||
121 | hPlugin.del( sPluginName ); | ||
122 | dlclose( pReg->dlHandle ); | ||
123 | delete pReg; | ||
124 | pReg = NULL; | ||
125 | } | ||
126 | |||
127 | pReg = new PluginReg; | ||
128 | |||
119 | pReg->bBuiltin = false; | 129 | pReg->bBuiltin = false; |
120 | pReg->dlHandle = dlopen( sFName, RTLD_NOW ); | 130 | pReg->dlHandle = dlopen( sFName, RTLD_NOW ); |
121 | if( pReg->dlHandle == NULL ) | 131 | if( pReg->dlHandle == NULL ) |
@@ -165,6 +175,20 @@ public: | |||
165 | hObj.del( pPlug ); | 175 | hObj.del( pPlug ); |
166 | } | 176 | } |
167 | 177 | ||
178 | void unloadAll() | ||
179 | { | ||
180 | std::list<PluginReg *>::iterator i; | ||
181 | for( i = lPlugin.begin(); i != lPlugin.end(); i++ ) | ||
182 | { | ||
183 | if( (*i)->bBuiltin == false ) | ||
184 | { | ||
185 | dlclose( (*i)->dlHandle ); | ||
186 | } | ||
187 | delete (*i); | ||
188 | } | ||
189 | hPlugin.clear(); | ||
190 | } | ||
191 | |||
168 | private: | 192 | private: |
169 | std::list<PluginReg *> lPlugin; | 193 | std::list<PluginReg *> lPlugin; |
170 | HashTable hPlugin; | 194 | HashTable hPlugin; |