1
0

cmDynamicLoader.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. // .NAME cmDynamicLoader - class interface to system dynamic libraries
  14. // .SECTION Description
  15. // cmDynamicLoader provides a portable interface to loading dynamic
  16. // libraries into a process.
  17. #ifndef __cmDynamicLoader_h
  18. #define __cmDynamicLoader_h
  19. #include "cmStandardIncludes.h"
  20. // Ugly stuff for library handles
  21. // They are different on several different OS's
  22. #if defined(__hpux)
  23. # include <dl.h>
  24. typedef shl_t cmLibHandle;
  25. #elif defined(_WIN32)
  26. #include <windows.h>
  27. typedef HMODULE cmLibHandle;
  28. #else
  29. typedef void* cmLibHandle;
  30. #endif
  31. class cmDynamicLoader
  32. {
  33. public:
  34. // Description:
  35. // Load a dynamic library into the current process.
  36. // The returned cmLibHandle can be used to access the symbols in the
  37. // library.
  38. static cmLibHandle OpenLibrary(const char*);
  39. // Description:
  40. // Attempt to detach a dynamic library from the
  41. // process. A value of true is returned if it is successful.
  42. static int CloseLibrary(cmLibHandle);
  43. // Description:
  44. // Find the address of the symbol in the given library
  45. static void* GetSymbolAddress(cmLibHandle, const char*);
  46. // Description:
  47. // Return the library prefix for the given architecture
  48. static const char* LibPrefix();
  49. // Description:
  50. // Return the library extension for the given architecture
  51. static const char* LibExtension();
  52. // Description:
  53. // Return the last error produced from a calls made on this class.
  54. static const char* LastError();
  55. protected:
  56. cmDynamicLoader() {};
  57. ~cmDynamicLoader() {};
  58. private:
  59. cmDynamicLoader(const cmDynamicLoader&); // Not implemented.
  60. void operator=(const cmDynamicLoader&); // Not implemented.
  61. };
  62. #endif