Gaudi Framework, version v22r1

Home   Generated: Mon Feb 28 2011
Defines | Functions | Variables

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)
std::string __typeName (char *&name)
std::string __className (char *&name)

Variables

static const char * SHLIB_SUFFIX = ".so"
static std::vector< std::strings_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.

                                   {
  std::string result;
  int j = 0, k, i;
  if ( 't' == *name ) {
    goto Template;
  }
  for ( i = ::strtol(name, &name, 10);  i > 0; i = ::strtol(name, &name, 10) ) {
    if ( j++ != 0 ) result.append("::",2);
    result.append(name, i);
    if ( *(name+=i) == 't' ) {
      result.append("::",2);
    Template:
      result.append(name, (i=::strtol(++name, &name, 10)));
      result.append("<");
      for (k = 0, i=::strtol(name+i, &name, 10); k < i; k++ ) {
        result += __typeName( ++name );
        if ( k+1 < i ) result += ",";
      }
      result.append(">");
    }
  }
  return result;
}
std::string __typeName ( char *&  name )

Definition at line 324 of file System.cpp.

                                   {
  if ( *name == 'Q' ) {              // Handle name spaces
    if ( *(++name) == '_' )          // >= 10 nested name spaces
      ::strtol(++name, &name, 10);   // type Q_##_...
    return __className(++name);
  }
  else if ( 't' == *name )  {
    return __className(name);
  }
  else  {
    std::string result;
    char* ptr;
    long i = ::strtol(name, &ptr, 10);
    if ( i <= 0 )  {
      name = ptr;
      while ( *name != 0 && *name != 'Z' )  {
        if ( *name == 'U' )  {
          result += "unsigned ";
          name++;
        }
        switch( *name++ )  {
        case 'c': result += "char"; break;
        case 's': result += "short"; break;
        case 'i': result += "int"; break;
        case 'l': result += "long"; break;
        case 'f': result += "float"; break;
        case 'd': result += "double"; break;
        default:  result += *(name-1);
        }
      }
      return result;
    }
    else {
      return __className(name);
    }
  }
}
static unsigned long doLoad ( const std::string name,
System::ImageHandle handle 
) [static]

Definition at line 75 of file System.cpp.

                                                                               {
#ifdef _WIN32
  void* mh = ::LoadLibrary( name.length() == 0 ? System::exeName().c_str() : name.c_str());
  *handle = mh;
#else
  const char* path = name.c_str();
#if defined(linux) || defined(__APPLE__)
  void *mh = ::dlopen(name.length() == 0 ? 0 : path, RTLD_LAZY | RTLD_GLOBAL);
  *handle = mh;
#elif __hpux
  shl_t mh = ::shl_load(name.length() == 0 ? 0 : path, BIND_IMMEDIATE | BIND_VERBOSE, 0);
  HMODULE* mod = new HMODULE;
  if ( 0 != mh ) {
    if ( 0 != ::shl_gethandle_r(mh, &mod->dsc) ) {
      std::cout << "System::loadDynamicLib>" << ::strerror(getLastError()) << std::endl;
    }
    else {
      typedef void* (*___all)();
      ___all _alloc = (___all)malloc;
      mod->numSym = ::shl_getsymbols(mod->dsc.handle, TYPE_PROCEDURE, EXPORT_SYMBOLS, malloc, &mod->sym);
      *handle = mod;
    }
  }
#endif
#endif
  if ( 0 == *handle )   {
    return System::getLastError();
  }
  return 1;
}
static unsigned long loadWithoutEnvironment ( const std::string name,
System::ImageHandle handle 
) [static]

Definition at line 106 of file System.cpp.

                                                                                                 {

  std::string dllName = name;
  long len = strlen(SHLIB_SUFFIX);

  // Add the suffix at the end of the library name only if necessary
  // FIXME: cure the logic
  if ((dllName.length() != 0) &&
      ::strncasecmp(dllName.data()+dllName.length()-len, SHLIB_SUFFIX, len) != 0) {
    dllName += SHLIB_SUFFIX;
  }

  // Load the library
  return doLoad(dllName, handle);
}

Variable Documentation

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

Definition at line 73 of file System.cpp.

Definition at line 72 of file System.cpp.

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

Definition at line 37 of file System.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Feb 28 2011 18:27:41 for Gaudi Framework, version v22r1 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004