| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# System.cpp File Reference

`#include <ctime>`
`#include <cstring>`
`#include <cstdlib>`
`#include <iomanip>`
`#include <iostream>`
`#include <sstream>`
`#include <typeinfo>`
`#include "GaudiKernel/System.h"`
`#include <errno.h>`
`#include <string.h>`
`#include "sys/times.h"`
`#include "unistd.h"`
`#include "libgen.h"`
`#include <cstdio>`
`#include <cxxabi.h>`

Include dependency graph for System.cpp:

Go to the source code of this file.

## Defines
#define | SYSTEM_SYSTEM_CPP
#define | __attribute__(x)
## Functions
static unsigned long | doLoad (const std::string &name, System::ImageHandle *handle)
static unsigned long | loadWithoutEnvironment (const std::string &name, System::ImageHandle *handle)
GAUDI_API unsigned long | System::loadDynamicLib (const std::string &name, ImageHandle *handle)
| Load dynamic link library.
GAUDI_API unsigned long | System::unloadDynamicLib (ImageHandle handle)
| unload dynamic link library
GAUDI_API unsigned long | System::getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction)
| Get a specific function defined in the DLL.
GAUDI_API unsigned long | System::getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction)
| Get a specific function defined in the DLL.
GAUDI_API unsigned long | System::getLastError ()
| Get last system known error.
GAUDI_API const std::string | System::getLastErrorString ()
| Get last system error as string.
GAUDI_API const std::string | System::getErrorString (unsigned long error)
| Retrieve error code as string for a given error.
std::string | __typeName (char *&name)
std::string | __className (char *&name)
GAUDI_API const std::string | System::typeinfoName (const std::type_info &)
| Get platform independent information about the class type.
GAUDI_API const std::string | System::typeinfoName (const char *)
GAUDI_API const std::string & | System::hostName ()
| Host name.
GAUDI_API const std::string & | System::osName ()
| OS name.
GAUDI_API const std::string & | System::osVersion ()
| OS version.
GAUDI_API const std::string & | System::machineType ()
| Machine type.
GAUDI_API const std::string & | System::accountName ()
| User login name.
GAUDI_API long | System::numCmdLineArgs ()
| Number of arguments passed to the commandline.
GAUDI_API long | System::argc ()
| Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
GAUDI_API const std::vector < std::string > | System::cmdLineArgs ()
| Command line arguments including executable name as arg[0] as vector of strings.
GAUDI_API char ** | System::argv ()
| char** command line arguments including executable name as arg[0]; You may not modify them!
GAUDI_API const std::string | System::getEnv (const char *var)
| get a particular environment variable
GAUDI_API const std::vector < std::string > | System::getEnv ()
| get all environment variables
int | System::backTrace (void **addresses __attribute__((unused)), const int depth __attribute__((unused)))
GAUDI_API bool | System::backTrace (std::string &btrace, const int depth, const int offset=0)
bool | System::getStackLevel (void *addresses __attribute__((unused)), void *&addr __attribute__((unused)), std::string &fnc __attribute__((unused)), std::string &lib __attribute__((unused)))
GAUDI_API int | System::setEnv (const std::string &name, const std::string &value, int overwrite=1)
| Set an environment variables.
## Variables
static const char * | SHLIB_SUFFIX = ".so"
static std::vector< std::string > | s_argvStrings
static std::vector< const char * > | s_argvChars

## Define Documentation

#define __attribute__ | ( | x |  | ) |

Definition at line 69 of file System.cpp.

#define SYSTEM_SYSTEM_CPP

Definition at line 14 of file System.cpp.

## Function Documentation

std::string __className | ( | char *& | name | ) |

Definition at line 300 of file System.cpp.

    00300                                    {
    00301   std::string result;
    00302   int j = 0, k, i;
    00303   if ( 't' == *name ) {
    00304     goto Template;
    00305   }
    00306   for ( i = ::strtol(name, &name, 10);  i > 0; i = ::strtol(name, &name, 10) ) {
    00307     if ( j++ != 0 ) result.append("::",2);
    00308     result.append(name, i);
    00309     if ( *(name+=i) == 't' ) {
    00310       result.append("::",2);
    00311     Template:
    00312       result.append(name, (i=::strtol(++name, &name, 10)));
    00313       result.append("<");
    00314       for (k = 0, i=::strtol(name+i, &name, 10); k < i; k++ ) {
    00315         result += __typeName( ++name );
    00316         if ( k+1 < i ) result += ",";
    00317       }
    00318       result.append(">");
    00319     }
    00320   }
    00321   return result;
    00322 }

std::string __typeName | ( | char *& | name | ) |

Definition at line 324 of file System.cpp.

    00324                                    {
    00325   if ( *name == 'Q' ) {              // Handle name spaces
    00326     if ( *(++name) == '_' )          // >= 10 nested name spaces
    00327       ::strtol(++name, &name, 10);   // type Q_##_...
    00328     return __className(++name);
    00329   }
    00330   else if ( 't' == *name )  {
    00331     return __className(name);
    00332   }
    00333   else  {
    00334     std::string result;
    00335     char* ptr;
    00336     long i = ::strtol(name, &ptr, 10);
    00337     if ( i <= 0 )  {
    00338       name = ptr;
    00339       while ( *name != 0 && *name != 'Z' )  {
    00340         if ( *name == 'U' )  {
    00341           result += "unsigned ";
    00342           name++;
    00343         }
    00344         switch( *name++ )  {
    00345         case 'c': result += "char"; break;
    00346         case 's': result += "short"; break;
    00347         case 'i': result += "int"; break;
    00348         case 'l': result += "long"; break;
    00349         case 'f': result += "float"; break;
    00350         case 'd': result += "double"; break;
    00351         default:  result += *(name-1);
    00352         }
    00353       }
    00354       return result;
    00355     }
    00356     else {
    00357       return __className(name);
    00358     }
    00359   }
    00360 }

static unsigned long doLoad | ( | const std::string & | name,
|  | System::ImageHandle * | handle |
| ) |  |  | `[static]`

Definition at line 75 of file System.cpp.

    00075                                                                                {
    00076 #ifdef _WIN32
    00077   void* mh = ::LoadLibrary( name.length() == 0 ? System::exeName().c_str() : name.c_str());
    00078   *handle = mh;
    00079 #else
    00080   const char* path = name.c_str();
    00081 #if defined(linux) || defined(__APPLE__)
    00082   void *mh = ::dlopen(name.length() == 0 ? 0 : path, RTLD_LAZY | RTLD_GLOBAL);
    00083   *handle = mh;
    00084 #elif __hpux
    00085   shl_t mh = ::shl_load(name.length() == 0 ? 0 : path, BIND_IMMEDIATE | BIND_VERBOSE, 0);
    00086   HMODULE* mod = new HMODULE;
    00087   if ( 0 != mh ) {
    00088     if ( 0 != ::shl_gethandle_r(mh, &mod->dsc) ) {
    00089       std::cout << "System::loadDynamicLib>" << ::strerror(getLastError()) << std::endl;
    00090     }
    00091     else {
    00092       typedef void* (*___all)();
    00093       ___all _alloc = (___all)malloc;
    00094       mod->numSym = ::shl_getsymbols(mod->dsc.handle, TYPE_PROCEDURE, EXPORT_SYMBOLS, malloc, &mod->sym);
    00095       *handle = mod;
    00096     }
    00097   }
    00098 #endif
    00099 #endif
    00100   if ( 0 == *handle )   {
    00101     return System::getLastError();
    00102   }
    00103   return 1;
    00104 }

static unsigned long loadWithoutEnvironment | ( | const std::string & | name,
|  | System::ImageHandle * | handle |
| ) |  |  | `[static]`

Definition at line 106 of file System.cpp.

    00106                                                                                                  {
    00107
    00108   std::string dllName = name;
    00109   long len = strlen(SHLIB_SUFFIX);
    00110
    00111   // Add the suffix at the end of the library name only if necessary
    00112   // FIXME: cure the logic
    00113   if ((dllName.length() != 0) &&
    00114       ::strncasecmp(dllName.data()+dllName.length()-len, SHLIB_SUFFIX, len) != 0) {
    00115     dllName += SHLIB_SUFFIX;
    00116   }
    00117
    00118   // Load the library
    00119   return doLoad(dllName, handle);
    00120 }

## Variable Documentation

std::vector<const char*> s_argvChars`[static]`

Definition at line 73 of file System.cpp.

std::vector<std::string> s_argvStrings`[static]`

Definition at line 72 of file System.cpp.

const char* SHLIB_SUFFIX = ".so"`[static]`

Definition at line 37 of file System.cpp.