cgma
CubitDynamicLoader.hpp
Go to the documentation of this file.
00001 
00002 #ifndef DYNAMIC_LOADER_HPP
00003 #define DYNAMIC_LOADER_HPP
00004 
00005 #if defined(__hpux)
00006 #  include <dl.h>
00007 #elif defined(_WIN32)
00008 #  define WIN32_LEAN_AND_MEAN
00009 #  ifndef NOMINMAX
00010 #    define NOMINMAX
00011 #  endif
00012 #  include <windows.h>
00013 #endif
00014 
00015 #include "CubitDefines.h"
00016 #include "CubitString.hpp"
00017 #include "CGMUtilConfigure.h"
00018 
00019 namespace CubitDynamicLoader
00020 {
00021 #if defined(__hpux)
00022   typedef shl_t LibraryHandle;
00023 #elif defined(_WIN32)
00024   typedef HMODULE LibraryHandle;
00025 #else
00026   typedef void* LibraryHandle;
00027 #endif
00028   
00029   // add a search path
00030   CUBIT_UTIL_EXPORT void add_search_path(const char* path);
00031 
00032   // check for if a library exists, only uses search paths specified
00033   CUBIT_UTIL_EXPORT CubitBoolean library_exists(const char* library);
00034   
00035   // open a library
00036   // a full path may / or may not be specified
00037   // use library_prefix(), library_extension() to help construct the library name
00038   CUBIT_UTIL_EXPORT LibraryHandle load_library(const char* library);
00039   
00040   // return the last error
00041   CUBIT_UTIL_EXPORT CubitString get_error();
00042 
00043   // close a library
00044   // success is returned
00045   CUBIT_UTIL_EXPORT CubitStatus unload_library(LibraryHandle);
00046   
00047   // get the address of a symbol in a give library
00048   CUBIT_UTIL_EXPORT void* get_symbol_address(LibraryHandle, const char*);
00049   
00050   // returns the library prefix for the given architecture
00051   CUBIT_UTIL_EXPORT const char* library_prefix();
00052   
00053   // returns the library extension for the given architecture
00054   CUBIT_UTIL_EXPORT const char* library_extension();
00055 
00056   // handle to check for load failures
00057   extern CUBIT_UTIL_EXPORT LibraryHandle InvalidLibraryHandle;
00058 
00059 }
00060 
00061 #endif
00062 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines