00001 /* 00002 * lib/module/pool.h 00003 * 00004 * Implementing shared objects loadable at runtime (.so, .dll, ...) 00005 * 00006 * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 00007 * 00008 * This file may be distributed and/or modified under the terms of the 00009 * GNU General Public License version 2 as published by the Free Software 00010 * Foundation. (See COPYING.GPL for details.) 00011 * 00012 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 * 00015 */ 00016 00017 #ifndef _LIB_MODULE_POOL_H_ 00018 #define _LIB_MODULE_POOL_H_ 1 00019 00114 #include <lib/sconfig.h> /* MUST be first */ 00115 00116 #include <lib/tl/linkedlist.h> 00117 #include <lib/threads/mutex.h> 00118 #include <lib/module/sharedobject.h> 00119 00120 #include <gmodule/gmodule.h> 00121 00122 // As defined in symbol.h: 00123 class ModuleSymbol; 00124 00136 class ModulePool 00137 { 00138 private: 00140 static ModulePool *pool; 00141 00142 private: 00150 LinkedList<_ISharedObject> so_list; 00152 RecursiveMutex pool_mutex; 00153 00155 SharedObject _load(const char *name,int flags); 00156 00158 int _unload(const char *name); 00159 00161 void _unregister(_ISharedObject *iso); 00162 00164 _ISharedObject *_FindObjectByName(const char *name,bool requeue); 00165 00167 ModulePool(const ModulePool &); 00168 void operator=(const ModulePool &); 00170 ModulePool(); 00171 public: 00172 ~ModulePool(); 00173 00185 static int init(); 00186 00192 static void cleanup(); 00193 00214 static inline SharedObject load(const char *name,int flags=0) 00215 { return(pool->_load(name,flags)); } 00216 00232 static inline int unload(const char *name) 00233 { return(pool->_unload(name)); } 00234 00239 static inline void unregister(_ISharedObject *iso) 00240 { pool->_unregister(iso); } 00241 }; 00242 00243 #endif /* _LIB_MODULE_POOL_H_ */