00001 /* 00002 * lib/module/sharedobject.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_SHAREDOBJECT_H_ 00018 #define _LIB_MODULE_SHAREDOBJECT_H_ 1 00019 00028 #include <lib/sconfig.h> /* MUST be first */ 00029 #include <lib/tl/refnode.h> 00030 #include <lib/tl/linkedlist.h> 00031 00032 #include <gmodule/gmodule.h> 00033 00042 class _ISharedObject_Namespace 00043 { 00044 public: 00045 enum Flags 00046 { 00050 BindLazy = G_MODULE_BIND_LAZY, 00056 BindLocal = G_MODULE_BIND_LOCAL, 00057 }; 00058 }; 00059 00060 00061 // As defined in pool.h: 00062 class ModulePool; 00063 // As defined in symbol.h: 00064 class ModuleSymbol; 00065 00066 00079 class _ISharedObject : 00080 public _ISharedObject_Namespace, 00081 private LinkedListBase<_ISharedObject>, // <-- List held by ModulePool. 00082 public InternalRefNodeBase_ThreadSave 00083 { 00084 friend class LinkedList<_ISharedObject>; 00085 friend class ModulePool; 00086 private: 00087 GModule *module; 00088 const char *mname; 00089 00091 _ISharedObject(const _ISharedObject &); 00092 void operator=(const _ISharedObject &); 00094 _ISharedObject(GModule *m,const char *name); 00095 public: 00097 ~_ISharedObject(); 00098 00100 inline const char *error() const 00101 { return(module ? NULL : mname); } // <-- CORRECT!!! 00102 00104 inline const char *name() const 00105 { return(module ? mname : NULL); } 00106 00114 ModuleSymbol lookup(const char *symbol); 00115 }; 00116 00117 00124 typedef RefNode<_ISharedObject,_ISharedObject_Namespace> SharedObject; 00125 00126 #endif /* _LIB_MODULE_SHAREDOBJECT_H_ */