00001 // 00002 // SharedLibrary.cpp 00003 // 00004 // $Id: //poco/1.3/Foundation/src/SharedLibrary.cpp#1 $ 00005 // 00006 // Library: Foundation 00007 // Package: SharedLibrary 00008 // Module: SharedLibrary 00009 // 00010 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 00011 // and Contributors. 00012 // 00013 // Permission is hereby granted, free of charge, to any person or organization 00014 // obtaining a copy of the software and accompanying documentation covered by 00015 // this license (the "Software") to use, reproduce, display, distribute, 00016 // execute, and transmit the Software, and to prepare derivative works of the 00017 // Software, and to permit third-parties to whom the Software is furnished to 00018 // do so, all subject to the following: 00019 // 00020 // The copyright notices in the Software and this entire statement, including 00021 // the above license grant, this restriction and the following disclaimer, 00022 // must be included in all copies of the Software, in whole or in part, and 00023 // all derivative works of the Software, unless such copies or derivative 00024 // works are solely in the form of machine-executable object code generated by 00025 // a source language processor. 00026 // 00027 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00028 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00029 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 00030 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 00031 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 00032 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00033 // DEALINGS IN THE SOFTWARE. 00034 // 00035 00036 00037 #include "Poco/SharedLibrary.h" 00038 #include "Poco/Exception.h" 00039 00040 00041 #if defined(hpux) || defined(_hpux) 00042 #include "SharedLibrary_HPUX.cpp" 00043 #elif defined(POCO_OS_FAMILY_UNIX) 00044 #include "SharedLibrary_UNIX.cpp" 00045 #elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) 00046 #include "SharedLibrary_WIN32U.cpp" 00047 #elif defined(POCO_OS_FAMILY_WINDOWS) 00048 #include "SharedLibrary_WIN32.cpp" 00049 #elif defined(POCO_OS_FAMILY_VMS) 00050 #include "SharedLibrary_VMS.cpp" 00051 #endif 00052 00053 00054 namespace Poco { 00055 00056 00057 SharedLibrary::SharedLibrary() 00058 { 00059 } 00060 00061 00062 SharedLibrary::SharedLibrary(const std::string& path) 00063 { 00064 loadImpl(path); 00065 } 00066 00067 00068 SharedLibrary::~SharedLibrary() 00069 { 00070 } 00071 00072 00073 void SharedLibrary::load(const std::string& path) 00074 { 00075 loadImpl(path); 00076 } 00077 00078 00079 void SharedLibrary::unload() 00080 { 00081 unloadImpl(); 00082 } 00083 00084 00085 bool SharedLibrary::isLoaded() const 00086 { 00087 return isLoadedImpl(); 00088 } 00089 00090 00091 bool SharedLibrary::hasSymbol(const std::string& name) 00092 { 00093 return findSymbolImpl(name) != 0; 00094 } 00095 00096 00097 void* SharedLibrary::getSymbol(const std::string& name) 00098 { 00099 void* result = findSymbolImpl(name); 00100 if (result) 00101 return result; 00102 else 00103 throw NotFoundException(name); 00104 } 00105 00106 00107 const std::string& SharedLibrary::getPath() const 00108 { 00109 return getPathImpl(); 00110 } 00111 00112 00113 std::string SharedLibrary::suffix() 00114 { 00115 return suffixImpl(); 00116 } 00117 00118 00119 } // namespace Poco