![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * D y n a m i c L i n k L i b r a r y S u p p o r t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2002,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXDLL.h,v 1.27 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXDLL_H 00024 #define FXDLL_H 00025 00026 namespace FX { 00027 00028 00029 /** 00030 * Wrap library module handle to allow various operations 00031 * on libraries to be performed. 00032 */ 00033 class FXAPI FXDLL { 00034 private: 00035 void *hnd; 00036 public: 00037 00038 /// Construct with no handle 00039 FXDLL():hnd(NULL){} 00040 00041 /// Construct with existing handle 00042 FXDLL(void *h):hnd(h){} 00043 00044 /// Construct copy from original 00045 FXDLL(const FXDLL& org):hnd(org.hnd){} 00046 00047 /// Return the name of the library module 00048 FXString name() const; 00049 00050 /// Return library module handle 00051 void* handle() const { return hnd; } 00052 00053 /// True if library was loaded 00054 FXbool loaded() const { return hnd!=NULL; } 00055 00056 /// Load the library module from the name 00057 FXbool load(const FXString& nm); 00058 00059 /// Unload the library module 00060 void unload(); 00061 00062 /// Return the address of the symbol in this library module 00063 void* address(const FXchar* sym) const; 00064 void* address(const FXString& sym) const; 00065 00066 /// Return the symbol name of the given address 00067 static FXString symbol(void *addr); 00068 00069 /// Return the name of the library module containing the address 00070 static FXString name(void *addr); 00071 00072 /// Find DLL containing symbol 00073 static FXDLL dll(void* addr); 00074 00075 /// Find DLL of ourselves 00076 static FXDLL dll(); 00077 00078 /// Return error message if error occurred loading the library module 00079 static FXString error(); 00080 }; 00081 00082 00083 /** 00084 * Auto DLL wraps a library module handle but also owns it; thus, the library 00085 * module will automatically be unloaded when auto-dll is destroyed. 00086 */ 00087 class FXAPI FXAUTODLL : public FXDLL { 00088 private: 00089 FXAUTODLL(const FXAUTODLL&); 00090 FXAUTODLL &operator=(const FXAUTODLL&); 00091 public: 00092 00093 /// Initialize by loading given library name 00094 FXAUTODLL(const FXString& nm); 00095 00096 /// Unload library if we have one 00097 ~FXAUTODLL(); 00098 }; 00099 00100 00101 } 00102 00103 #endif 00104
![]() |