cgma
CubitDynamicLoader Namespace Reference

Typedefs

typedef void * LibraryHandle

Functions

CUBIT_UTIL_EXPORT void add_search_path (const char *path)
CUBIT_UTIL_EXPORT CubitBoolean library_exists (const char *library)
CUBIT_UTIL_EXPORT LibraryHandle load_library (const char *library)
CUBIT_UTIL_EXPORT CubitString get_error ()
CUBIT_UTIL_EXPORT CubitStatus unload_library (LibraryHandle)
CUBIT_UTIL_EXPORT void * get_symbol_address (LibraryHandle, const char *)
CUBIT_UTIL_EXPORT const char * library_prefix ()
CUBIT_UTIL_EXPORT const char * library_extension ()

Variables

CUBIT_UTIL_EXPORT LibraryHandle InvalidLibraryHandle = NULL

Typedef Documentation

Definition at line 26 of file CubitDynamicLoader.hpp.


Function Documentation

void CubitDynamicLoader::add_search_path ( const char *  path)

Definition at line 15 of file CubitDynamicLoader.cpp.

{
  gSearchPaths.push_back(CubitString(path));
}

Definition at line 224 of file CubitDynamicLoader.cpp.

{
  return dlerror();
}

Definition at line 234 of file CubitDynamicLoader.cpp.

{
  return dlsym(lib, symbol);
}

Definition at line 31 of file CubitDynamicLoader.cpp.

{
  struct stat buf;

  // if absolute path, test it directly
  if(absolute_path(library))
  {
    return stat(library, &buf) == 0 ? CUBIT_TRUE : CUBIT_FALSE;
  }
  else
  { 
    // try finding with our search paths
    for(int i=0; i<(int)gSearchPaths.size(); i++)
    {
      CubitString path = gSearchPaths[i] + CubitString("/") + library;
      if(stat(path.c_str(), &buf) == 0)
        return CUBIT_TRUE;
    }
  }
  
  // one more final attempt
  if (stat(library, &buf) == 0)
    return CUBIT_TRUE;

  return CUBIT_FALSE;
}

Definition at line 244 of file CubitDynamicLoader.cpp.

{
  return ".so";
}

Definition at line 239 of file CubitDynamicLoader.cpp.

{
  return "lib";
}

Definition at line 201 of file CubitDynamicLoader.cpp.

{
  // if absolute path, test it directly
  if(absolute_path(lib))
  {
    return dlopen(lib, RTLD_LAZY);
  }
  else
  { 
    // try finding with our search paths
    for(int i=0; i<(int)gSearchPaths.size(); i++)
    {
      CubitString path = gSearchPaths[i]+CubitString("/")+lib;
      LibraryHandle handle = dlopen(path.c_str(), RTLD_LAZY);
      if(handle != InvalidLibraryHandle)
        return handle;
    }
  }
  
  // one more final attempt
  return dlopen(lib, RTLD_LAZY );
}

Variable Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines