NCBI C++ ToolKit
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
CDll Class Reference

Search Toolkit Book for CDll

CDll –. More...

#include <corelib/ncbidll.hpp>

+ Collaboration diagram for CDll:

Classes

union  TEntryPoint
 Entry point – pointer to either a function or a data. More...
 

Public Types

enum  EFlags {
  fLoadNow = (1<<1) , fLoadLater = (1<<2) , fAutoUnload = (1<<3) , fNoAutoUnload = (1<<4) ,
  fBaseName = (1<<5) , fExactName = (1<<6) , fGlobal = (1<<7) , fLocal = (1<<8) ,
  fDefault = fLoadNow | fNoAutoUnload | fBaseName | fGlobal
}
 General flags. More...
 
enum  ELoad { eLoadNow = fLoadNow , eLoadLater = fLoadLater }
 When to load DLL. More...
 
enum  EAutoUnload { eAutoUnload = fAutoUnload , eNoAutoUnload = fNoAutoUnload }
 Whether to unload DLL in the destructor. More...
 
enum  EBasename { eBasename = fBaseName , eExactName = fExactName }
 Whether to transform the DLL basename. More...
 
typedef unsigned int TFlags
 Binary OR of "EFlags". More...
 
typedef void(* FEntryPoint) (char ****Do_Not_Call_This)
 Fake, uncallable function pointer. More...
 

Public Member Functions

 CDll (const string &name, TFlags flags)
 Constructor. More...
 
 CDll (const string &name, ELoad when_to_load=eLoadNow, EAutoUnload auto_unload=eNoAutoUnload, EBasename treate_as=eBasename)
 Constructor (for backward compatibility). More...
 
 CDll (const string &path, const string &name, TFlags flags)
 Constructor. More...
 
 CDll (const string &path, const string &name, ELoad when_to_load=eLoadNow, EAutoUnload auto_unload=eNoAutoUnload, EBasename treate_as=eBasename)
 Constructor (for backward compatibility). More...
 
 ~CDll (void)
 Destructor. More...
 
void Load (void)
 Load DLL. More...
 
void Unload (void)
 Unload DLL. More...
 
template<class TFunc >
TFunc GetEntryPoint_Func (const string &name, TFunc *func)
 Get DLLs entry point (function). More...
 
template<class TData >
TData GetEntryPoint_Data (const string &name, TData *data)
 Get DLLs entry point (data). More...
 
TEntryPoint GetEntryPoint (const string &name)
 Helper find method for getting a DLLs entry point. More...
 
const stringGetName () const
 Get the name of the DLL file. More...
 

Protected Member Functions

 CDll (const CDll &)
 Private copy constructor to prohibit copy. More...
 
CDlloperator= (const CDll &)
 Private assignment operator to prohibit assignment. More...
 

Private Member Functions

void x_ThrowException (const string &what)
 Helper method to throw exception with system-specific error message. More...
 
void x_Init (const string &path, const string &name, TFlags flags)
 Helper method to initialize object. More...
 

Private Attributes

string m_Name
 DLL name. More...
 
SDllHandlem_Handle
 DLL handle. More...
 
TFlags m_Flags
 Flags. More...
 

Detailed Description

CDll –.

Define class for portable Dll handling.

The DLL name is considered the basename if it does not contain embedded '/', '\', or ':' symbols. Also, in this case, if the DLL name does not start with NCBI_PLUGIN_PREFIX and contain NCBI_PLUGIN_MIN_SUFFIX (and if eExactName flag not passed to the constructor), then it will be automatically transformed according to the following rule: <name> —> NCBI_PLUGIN_PREFIX + <name> + NCBI_PLUGIN_SUFFIX

If the DLL is specified by its basename, then it will be searched (after the transformation described above) in the following locations:

UNIX: 1) the directories that are listed in the LD_LIBRARY_PATH environment variable (analyzed once at the process startup); 2) the directory from which the application loaded; 3) hard-coded (e.g. with `ldconfig' on Linux) paths.

MS Windows: 1) the directory from which the application is loaded; 2) the current directory; 3) the Windows system directory; 4) the Windows directory; 5) the directories that are listed in the PATH environment variable.

NOTE: All methods of this class except the destructor throw exception CCoreException::eDll on error.

Definition at line 106 of file ncbidll.hpp.


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:57:32 2024 by modify_doxy.py rev. 669887