Kea 2.7.6
isc::hooks::PointerConverter Class Reference

Local class for conversion of void pointers to function pointers. More...

#include <pointer_converter.h>

Public Member Functions

 PointerConverter (CalloutPtr callout_ptr)
 Constructor.
 
 PointerConverter (void *dlsym_ptr)
 Constructor.
 
Pointer accessor functions

It is up to the caller to ensure that the correct member is called so that the correct type of pointer is returned.

void * dlsymPtr () const
 Return pointer returned by dlsym call.
 
CalloutPtr calloutPtr () const
 Return pointer to callout function.
 
load_function_ptr loadPtr () const
 Return pointer to load function.
 
unload_function_ptr unloadPtr () const
 Return pointer to unload function.
 
version_function_ptr versionPtr () const
 Return pointer to version function.
 
multi_threading_compatible_function_ptr multiThreadingCompatiblePtr () const
 Return pointer to multi_threading_compatible function.
 

Detailed Description

Local class for conversion of void pointers to function pointers.

Converting between void* and function pointers in C++ is fraught with difficulty and pitfalls, e.g. see https://groups.google.com/forum/?hl=en&fromgroups#!topic/comp.lang.c++/37o0l8rtEE0

The method given in that article - convert using a union is used here. A union is declared (and zeroed) and the appropriate member extracted when needed.

Definition at line 25 of file pointer_converter.h.

Constructor & Destructor Documentation

◆ PointerConverter() [1/2]

isc::hooks::PointerConverter::PointerConverter ( void * dlsym_ptr)
inline

Constructor.

Zeroes the union and stores the void* pointer we wish to convert (the one returned by dlsym).

Parameters
dlsym_ptrvoid* pointer returned by call to dlsym()

Definition at line 33 of file pointer_converter.h.

References dlsym_ptr.

◆ PointerConverter() [2/2]

isc::hooks::PointerConverter::PointerConverter ( CalloutPtr callout_ptr)
inline

Constructor.

Zeroes the union and stores the CalloutPtr pointer we wish to convert. This constructor is used in debug messages; output of a pointer to an object (including to a function) is, on some compilers, printed as "1".

Parameters
callout_ptrPointer to callout function

Definition at line 46 of file pointer_converter.h.

References callout_ptr.

Member Function Documentation

◆ calloutPtr()

CalloutPtr isc::hooks::PointerConverter::calloutPtr ( ) const
inline

Return pointer to callout function.

Returns
Pointer to the callout function

Definition at line 70 of file pointer_converter.h.

Referenced by isc::hooks::LibraryManager::registerStandardCallouts().

◆ dlsymPtr()

void * isc::hooks::PointerConverter::dlsymPtr ( ) const
inline

Return pointer returned by dlsym call.

Returns
void* pointer returned by the call to dlsym(). This can be used in statements that print the hexadecimal value of the symbol.

Definition at line 63 of file pointer_converter.h.

Referenced by isc::hooks::CalloutManager::callCallouts().

◆ loadPtr()

load_function_ptr isc::hooks::PointerConverter::loadPtr ( ) const
inline

Return pointer to load function.

Returns
Pointer to the load function

Definition at line 77 of file pointer_converter.h.

Referenced by isc::hooks::LibraryManager::runLoad().

◆ multiThreadingCompatiblePtr()

multi_threading_compatible_function_ptr isc::hooks::PointerConverter::multiThreadingCompatiblePtr ( ) const
inline

Return pointer to multi_threading_compatible function.

Returns
Pointer to the multi_threading_compatible function

Definition at line 98 of file pointer_converter.h.

Referenced by isc::hooks::LibraryManager::checkMultiThreadingCompatible().

◆ unloadPtr()

unload_function_ptr isc::hooks::PointerConverter::unloadPtr ( ) const
inline

Return pointer to unload function.

Returns
Pointer to the unload function

Definition at line 84 of file pointer_converter.h.

Referenced by isc::hooks::LibraryManager::prepareUnloadLibrary().

◆ versionPtr()

version_function_ptr isc::hooks::PointerConverter::versionPtr ( ) const
inline

Return pointer to version function.

Returns
Pointer to the version function

Definition at line 91 of file pointer_converter.h.

Referenced by isc::hooks::LibraryManager::checkVersion().

Member Data Documentation

◆ callout_ptr

CalloutPtr isc::hooks::PointerConverter::callout_ptr

Definition at line 109 of file pointer_converter.h.

Referenced by PointerConverter().

◆ dlsym_ptr

void* isc::hooks::PointerConverter::dlsym_ptr

Definition at line 108 of file pointer_converter.h.

Referenced by PointerConverter().

◆ load_ptr

load_function_ptr isc::hooks::PointerConverter::load_ptr

Definition at line 110 of file pointer_converter.h.

◆ multi_threading_compatible_ptr

multi_threading_compatible_function_ptr isc::hooks::PointerConverter::multi_threading_compatible_ptr

Definition at line 113 of file pointer_converter.h.

◆ unload_ptr

unload_function_ptr isc::hooks::PointerConverter::unload_ptr

Definition at line 111 of file pointer_converter.h.

◆ version_ptr

version_function_ptr isc::hooks::PointerConverter::version_ptr

Definition at line 112 of file pointer_converter.h.


The documentation for this class was generated from the following file: