#include <DLL.h>
Collaboration diagram for ACE_DLL:
Public Member Functions | |
ACE_DLL (int close_handle_on_destruction=1) | |
const ACE_DLL & | operator= (const ACE_DLL &rhs) |
Allow assignment. | |
ACE_DLL (const ACE_TCHAR *dll_name, int open_mode=ACE_DEFAULT_SHLIB_MODE, int close_handle_on_destruction=1) | |
ACE_DLL (const ACE_DLL &) | |
Copy constructor. | |
int | open (const ACE_TCHAR *dll_name, int open_mode=ACE_DEFAULT_SHLIB_MODE, int close_handle_on_destruction=1) |
int | close (void) |
Call to close the DLL object. | |
~ACE_DLL (void) | |
void * | symbol (const ACE_TCHAR *symbol_name, int ignore_errors=0) |
ACE_TCHAR * | error (void) const |
ACE_SHLIB_HANDLE | get_handle (int become_owner=0) const |
int | set_handle (ACE_SHLIB_HANDLE handle, int close_handle_on_destruction=1) |
Set the handle for the DLL object. By default, the close(). | |
Public Attributes | |
int | open_mode_ |
Open mode. | |
ACE_TCHAR * | dll_name_ |
int | close_handle_on_destruction_ |
ACE_DLL_Handle * | dll_handle_ |
int | error_ |
Flag to record if the last operation had an error. | |
Private Member Functions | |
int | open_i (const ACE_TCHAR *dll_name, int open_mode=ACE_DEFAULT_SHLIB_MODE, int close_handle_on_destruction=1, ACE_SHLIB_HANDLE handle=0) |
This class is a wrapper over the various methods for utilizing a dynamically linked library (DLL), which is called a shared library on some platforms. Operations open()
, close()
, and symbol()
have been implemented to help opening/closing and extracting symbol information from a DLL, respectively.
Definition at line 42 of file DLL.h.
|
Default constructor. By default, the close() operation on the object will be invoked before it is destroyed.
Definition at line 19 of file DLL.cpp. References ACE_TRACE.
00020 : open_mode_ (0), 00021 dll_name_ (0), 00022 close_handle_on_destruction_ (close_handle_on_destruction), 00023 dll_handle_ (0), 00024 error_ (0) 00025 { 00026 ACE_TRACE ("ACE_DLL::ACE_DLL (int)"); 00027 } |
|
This constructor performs the actions of open() during construction.
Definition at line 79 of file DLL.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, ACE::debug(), LM_ERROR, and open().
00082 : open_mode_ (open_mode), 00083 dll_name_ (0), 00084 close_handle_on_destruction_ (close_handle_on_destruction), 00085 dll_handle_ (0), 00086 error_ (0) 00087 { 00088 ACE_TRACE ("ACE_DLL::ACE_DLL"); 00089 00090 if (this->open (dll_name, this->open_mode_, close_handle_on_destruction) != 0 00091 && ACE::debug ()) 00092 ACE_ERROR ((LM_ERROR, 00093 ACE_LIB_TEXT ("ACE_DLL::open: error calling open: %s\n"), 00094 this->error ())); 00095 } |
|
Copy constructor.
Definition at line 29 of file DLL.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, close_handle_on_destruction_, ACE::debug(), dll_name_, LM_ERROR, open(), and open_mode_.
00030 : open_mode_ (0), 00031 dll_name_ (0), 00032 close_handle_on_destruction_ (0), 00033 dll_handle_ (0), 00034 error_ (0) 00035 { 00036 ACE_TRACE ("ACE_DLL::ACE_DLL (const ACE_DLL &)"); 00037 00038 if (rhs.dll_name_ 00039 // This will automatically up the refcount. 00040 && this->open (rhs.dll_name_, 00041 rhs.open_mode_, 00042 rhs.close_handle_on_destruction_) != 0 00043 && ACE::debug ()) 00044 ACE_ERROR ((LM_ERROR, 00045 ACE_LIB_TEXT ("ACE_DLL::copy_ctor: error: %s\n"), 00046 this->error ())); 00047 } |
|
Called when the DLL object is destroyed -- invokes close() if the close_handle_on_destruction flag was set to non-zero in the constructor or open() method. Definition at line 101 of file DLL.cpp. References ACE_TRACE, close(), and dll_name_.
00102 { 00103 ACE_TRACE ("ACE_DLL::~ACE_DLL"); 00104 00105 this->close (); 00106 00107 // Normally delete()d in ACE_DLL::close(). However, that may not 00108 // occur if full ACE_DLL initialization is interrupted due to errors 00109 // (e.g. attempting to open a DSO/DLL that does not exist). Make 00110 // sure this->dll_name_ is deallocated. 00111 delete [] this->dll_name_; 00112 } |
|
Call to close the DLL object.
Definition at line 203 of file DLL.cpp. References ACE_TRACE, ACE_DLL_Manager::close_dll(), close_handle_on_destruction_, dll_handle_, dll_name_, error_, and ACE_DLL_Manager::instance(). Referenced by open_i(), and ~ACE_DLL().
00204 { 00205 ACE_TRACE ("ACE_DLL::close"); 00206 00207 int retval = 0; 00208 00209 if (this->dll_handle_ 00210 && this->close_handle_on_destruction_ 00211 && this->dll_name_ 00212 && (retval = ACE_DLL_Manager::instance ()->close_dll (this->dll_name_)) != 0) 00213 this->error_ = 1; 00214 00215 // Even if close_dll() failed, go ahead and cleanup. 00216 this->dll_handle_ = 0; 00217 delete [] this->dll_name_; 00218 this->dll_name_ = 0; 00219 this->close_handle_on_destruction_ = 0; 00220 00221 return retval; 00222 } |
|
Returns a pointer to a string explaining that an error occured. You will need to consult the error log for the actual error string returned by the OS. Definition at line 227 of file DLL.cpp. References ACE_LIB_TEXT, ACE_TRACE, and error_. Referenced by ACE_Location_Node::open_dll(), ACE_Function_Node::symbol(), and ACE_Object_Node::symbol().
00228 { 00229 ACE_TRACE ("ACE_DLL::error"); 00230 if (this->error_) 00231 return 00232 const_cast<ACE_TCHAR *> (ACE_LIB_TEXT ("Error: check log for details.")); 00233 00234 return 0; 00235 } |
|
Return the handle to the caller. If become_owner is non-0 then caller assumes ownership of the handle and the ACE_DLL object won't call close() when it goes out of scope, even if is set. Definition at line 242 of file DLL.cpp. References ACE_SHLIB_HANDLE, ACE_SHLIB_INVALID_HANDLE, ACE_TRACE, dll_handle_, and ACE_DLL_Handle::get_handle().
00243 { 00244 ACE_TRACE ("ACE_DLL::get_handle"); 00245 00246 ACE_SHLIB_HANDLE handle = ACE_SHLIB_INVALID_HANDLE; 00247 00248 if (this->dll_handle_) 00249 handle = this->dll_handle_->get_handle (become_owner); 00250 00251 return handle; 00252 } |
|
This method opens and dynamically links a specified DLL.
Definition at line 126 of file DLL.cpp. References ACE_TCHAR, ACE_TRACE, and open_i(). Referenced by ACE_DLL(), ACE_Location_Node::open_dll(), and operator=().
|
|
Definition at line 136 of file DLL.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_SHLIB_HANDLE, ACE_TCHAR, ACE_TRACE, close(), close_handle_on_destruction_, ACE::debug(), dll_handle_, dll_name_, error_, ACE_DLL_Manager::instance(), LM_ERROR, ACE_DLL_Manager::open_dll(), open_mode_, ACE_OS::strcmp(), and ACE::strnew(). Referenced by open(), and set_handle().
00140 { 00141 ACE_TRACE ("ACE_DLL::open_i"); 00142 00143 this->error_ = 0; 00144 00145 if (!dll_filename) 00146 { 00147 if (ACE::debug ()) 00148 ACE_ERROR ((LM_ERROR, 00149 ACE_LIB_TEXT ("ACE_DLL::open_i: dll_name is %s\n"), 00150 this->dll_name_ == 0 ? ACE_LIB_TEXT ("(null)") 00151 : this->dll_name_)); 00152 return -1; 00153 } 00154 00155 if (this->dll_handle_) 00156 { 00157 // If we have a good handle and its the same name, just return. 00158 if (ACE_OS::strcmp (this->dll_name_, dll_filename) == 0) 00159 return 0; 00160 else 00161 this->close (); 00162 } 00163 00164 if (!this->dll_name_) 00165 this->dll_name_ = ACE::strnew (dll_filename); 00166 00167 this->open_mode_ = open_mode; 00168 this->close_handle_on_destruction_ = close_handle_on_destruction; 00169 00170 this->dll_handle_ = ACE_DLL_Manager::instance()->open_dll (this->dll_name_, 00171 this->open_mode_, 00172 handle); 00173 00174 if (!this->dll_handle_) 00175 this->error_ = 1; 00176 00177 return this->error_ ? -1 : 0; 00178 } |
|
Allow assignment.
Definition at line 52 of file DLL.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, close_handle_on_destruction_, ACE::debug(), dll_handle_, dll_name_, error_, LM_ERROR, open(), and open_mode_.
00053 { 00054 ACE_TRACE ("ACE_DLL::operator= (const ACE_DLL &)"); 00055 00056 open_mode_ = 0; 00057 dll_name_ = 0; 00058 close_handle_on_destruction_=0; 00059 dll_handle_=0; 00060 error_=0; 00061 00062 if (rhs.dll_name_ 00063 // This will automatically up the refcount and initialize *this 00064 && this->open (rhs.dll_name_, 00065 rhs.open_mode_, 00066 rhs.close_handle_on_destruction_) != 0 00067 && ACE::debug ()) 00068 ACE_ERROR ((LM_ERROR, 00069 ACE_LIB_TEXT ("ACE_DLL::operator=: error: %s\n"), 00070 this->error ())); 00071 00072 return *this; 00073 } |
|
Set the handle for the DLL object. By default, the close().
Definition at line 258 of file DLL.cpp. References ACE_SHLIB_HANDLE, ACE_TCHAR, ACE_TRACE, ACE_UNIQUE_NAME_LEN, open_i(), and ACE_OS::unique_name(). Referenced by ACE_Service_Type::ACE_Service_Type().
00260 { 00261 ACE_TRACE ("ACE_DLL::set_handle"); 00262 00263 // Create a unique name. Note that this name is only quaranteed 00264 // to be unique for the life of this object. 00265 ACE_TCHAR temp[ACE_UNIQUE_NAME_LEN]; 00266 ACE_OS::unique_name (this, temp, ACE_UNIQUE_NAME_LEN); 00267 00268 return this->open_i (temp, 1, close_handle_on_destruction, handle); 00269 } |
|
Look up a named symbol in the DLL. DLL must be successfully opened before calling symbol().
Definition at line 183 of file DLL.cpp. References ACE_TCHAR, ACE_TRACE, dll_handle_, error_, and ACE_DLL_Handle::symbol(). Referenced by ACE_Function_Node::symbol(), and ACE_Object_Node::symbol().
00184 { 00185 ACE_TRACE ("ACE_DLL::symbol"); 00186 00187 this->error_ = 0; 00188 00189 void *sym = 0; 00190 if (this->dll_handle_) 00191 sym = this->dll_handle_->symbol (sym_name, ignore_errors); 00192 00193 if (!sym) 00194 this->error_ = 1; 00195 00196 return sym; 00197 } |
|
This flag keeps track of whether we should close the handle automatically when the object is destroyed. Definition at line 184 of file DLL.h. Referenced by ACE_DLL(), close(), open_i(), and operator=(). |
|
Definition at line 186 of file DLL.h. Referenced by close(), get_handle(), open_i(), operator=(), and symbol(). |
|
Keep track of the name of the loaded dll, so it can be used to remove framework components, singletons that live in the dll, prior to unloading the dll in the close() method. Definition at line 180 of file DLL.h. Referenced by ACE_DLL(), close(), open_i(), operator=(), and ~ACE_DLL(). |
|
Flag to record if the last operation had an error.
Definition at line 189 of file DLL.h. Referenced by close(), error(), open_i(), operator=(), and symbol(). |
|
Open mode.
Definition at line 175 of file DLL.h. Referenced by ACE_DLL(), open_i(), and operator=(). |