Gaudi Framework, version v20r2

Generated: 18 Jul 2008

System Namespace Reference


Detailed Description

Note: OS specific details for environment resolution.

Entrypoints:

Author:
: M.Frank
Version:
: 1.0


Classes

class  PathResolver
struct  PROCESS_BASIC_INFORMATION
struct  QUOTA_LIMITS
 Process Quotas NtQueryInformationProcess using ProcessQuotaLimits NtQueryInformationProcess using ProcessPooledQuotaLimits NtSetInformationProcess using ProcessQuotaLimits. More...
struct  IO_COUNTERS
 Process I/O Counters NtQueryInformationProcess using ProcessIoCounters. More...
struct  VM_COUNTERS
 Process Virtual Memory Counters NtQueryInformationProcess using ProcessVmCounters. More...
struct  POOLED_USAGE_AND_LIMITS
 Process Pooled Quota Usage and Limits NtQueryInformationProcess using ProcessPooledUsageAndLimits. More...
struct  KERNEL_USER_TIMES
 Process/Thread System and User Time NtQueryInformationProcess using ProcessTimes NtQueryInformationThread using ThreadTimes. More...
class  ProcessDescriptor
 Provides access to process information. More...

Typedefs

typedef void * ImageHandle
 Definition of an image handle.
typedef void * ProcessHandle
 Definition of the process handle.
typedef void * ImageHandle
 Definition of an image handle.
typedef void * ProcessHandle
 Definition of the process handle.
typedef unsigned long(*) EntryPoint (const unsigned long iid, void **ppvObject)
 Definition of the "generic" DLL entry point function.
typedef void *(*) Creator ()
 Definition of the "generic" DLL entry point function.
typedef void * ThreadHandle
 A Thread handle.
typedef _PEB * PPEB
 Basic Process Information NtQueryInformationProcess using ProcessBasicInfo.

Enumerations

enum  MemoryUnit {
  Byte, kByte, MByte, GByte,
  TByte, PByte, EByte
}
 Unit of memory. More...
enum  ModuleType { UNKNOWN, SHAREDLIB, EXECUTABLE }
enum  InfoType {
  NoFetch, RemainTime, Times, ProcessBasics,
  PriorityBoost, Memory, Quota, System,
  Modules, IO
}
 Enumeration for fetching information. More...
enum  TimeType {
  Year, Month, Day, Hour,
  Min, Sec, milliSec, microSec,
  nanoSec
}
 Time type for conversion. More...
enum  PR_file_type { PR_regular_file, PR_directory }
enum  PR_search_type { PR_local, PR_recursive }
enum  ProcessInfoCommand {
  ProcessBasicInformation, ProcessQuotaLimits, ProcessIoCounters, ProcessVmCounters,
  ProcessTimes, ProcessBasePriority, ProcessRaisePriority, ProcessDebugPort,
  ProcessExceptionPort, ProcessAccessToken, ProcessLdtInformation, ProcessLdtSize,
  ProcessDefaultHardErrorMode, ProcessIoPortHandlers, ProcessPooledUsageAndLimits, ProcessWorkingSetWatch,
  ProcessUserModeIOPL, ProcessEnableAlignmentFaultFixup, ProcessPriorityClass, ProcessWx86Information,
  ProcessHandleCount, ProcessAffinityMask, ProcessPriorityBoost, MaxProcessInfoClass,
  ProcessEllapsedTime
}

Functions

long breakExecution ()
 Break the execution of the application and invoke the debugger.
long breakExecution (long pid)
 Break the execution of the application and invoke the debugger in a remote process.
std::string homeDirectory ()
std::string tempDirectory ()
StatusCode resolveEnv (const std::string &var, std::string &res, int recusions=124)
long adjustMemory (MemoryUnit typ, long value)
 Convert time from kByte to requested representation (Experts only).
long procID ()
 Basic Process Information: Process ID.
long parentID (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Parent's process ID.
long affinityMask (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Affinity mask.
long exitStatus (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Exit status (does not really make sense for the running process, but for others!).
long basePriority (InfoType fetch=ProcessBasics, long pid=-1)
 Basic Process Information: Base priority.
long priorityBoost (InfoType fetch=PriorityBoost, long pid=-1)
 Basic Process Information: priority boost.
long numPageFault (InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Number of page faults.
long pagefileUsage (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Current page file usage.
long pagefileUsagePeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Peak usage of page file.
long pagefileUsageLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 Basic Process Information: Peak usage of page file.
long nonPagedMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Current usage of non paged memory.
long nonPagedMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Peak usage of non paged memory.
long nonPagedMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Maximum amount of non-paged memory this process is allowed to use.
long pagedMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Amount of paged memory currently occupied by the process 'pid'.
long pagedMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: Maximum of paged memory occupied by the process 'pid'.
long pagedMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 Basic Process Information: Amount of paged memory that can be occupied by the process 'pid'.
long minMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Minimum amount of virtual memory this process may use.
long maxMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Maximum amount of virtual memory this process is allowed to use.
long mappedMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
long mappedMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
long virtualMemory (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
long virtualMemoryPeak (MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
 Basic Process Information: priority boost.
long virtualMemoryLimit (MemoryUnit unit=kByte, InfoType fetch=Quota, long pid=-1)
 System Process Limits: Maximum amount of the page file this process is allowed to use.
const std::stringmoduleName ()
 Get the name of the (executable/DLL) file without file-type.
const std::stringmoduleNameFull ()
 Get the full name of the (executable/DLL) file.
const ModuleType moduleType ()
 Get type of the module.
ProcessHandle processHandle ()
 Handle to running process.
ImageHandle moduleHandle ()
 Handle to currently executed module.
ImageHandle exeHandle ()
 Handle to the executable file running.
const std::stringexeName ()
 Name of the executable file running.
const std::vector< std::stringlinkedModules ()
 Vector of names of linked modules.
void setModuleHandle (ImageHandle handle)
 Attach module handle.
PathResolver::SearchPathStatus PathResolverCheckSearchPath (const std::string &search_path)
std::string PathResolverFindDirectory (const std::string &logical_file_name, const std::string &search_path)
std::string PathResolverFindDirectoryFromList (const std::string &logical_file_name, const std::string &search_list)
std::string PathResolverFindFile (const std::string &logical_file_name, const std::string &search_path)
std::string PathResolverFindFileFromList (const std::string &logical_file_name, const std::string &search_list)
std::string PathResolverFindXMLFile (const std::string &logical_file_name)
std::string PathResolverFindDataFile (const std::string &logical_file_name)
unsigned long loadDynamicLib (const std::string &name, ImageHandle *handle)
 Load dynamic link library.
unsigned long unloadDynamicLib (ImageHandle handle)
 unload dynamic link library
unsigned long getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction)
 Get a specific function defined in the DLL.
unsigned long getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction)
 Get a specific function defined in the DLL.
unsigned long getLastError ()
 Get last system known error.
const std::string getLastErrorString ()
 Get last system error as string.
const std::string getErrorString (unsigned long error)
 Retrieve error code as string for a given error.
const std::string typeinfoName (const std::type_info &)
 Get platform independent information about the class type.
const std::string typeinfoName (const char *)
const std::stringhostName ()
 Host name.
const std::stringosName ()
 OS name.
const std::stringosVersion ()
 OS version.
const std::stringmachineType ()
 Machine type.
const std::stringaccountName ()
 User login name.
long numCmdLineArgs ()
 Number of arguments passed to the commandline.
long argc ()
 Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
const std::vector< std::stringcmdLineArgs ()
 Command line arguments including executable name as arg[0] as vector of strings.
char ** argv ()
 char** command line arguments including executable name as arg[0]; You may not modify them!
const std::string getEnv (const char *var)
 get a particular environment variable
const std::vector< std::stringgetEnv ()
 get all environment variables
int setEnv (const std::string &name, const std::string &value, int overwrite=1)
 Set an environment variables.
ThreadHandle threadSelf ()
 thread handle "accessor"
bool backTrace (void **addresses, const size_t depth)
bool getStackLevel (void *addresses, void *&addr, std::string &fnc, std::string &lib)
longlong adjustTime (TimeType typ, longlong timevalue)
 Convert time from OS native time to requested representation (Experts only).
longlong ellapsedTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 Ellapsed time since start of process in milli seconds.
longlong kernelTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 CPU kernel mode time of process in milli seconds.
longlong userTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 CPU user mode time of process in milli seconds.
longlong cpuTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 Consumed CPU time of process in milli seconds.
longlong remainingTime (TimeType typ=milliSec, InfoType fetch=Quota, long pid=-1)
 Maximum processing time left for this process.
longlong creationTime (TimeType typ=milliSec, InfoType fetch=Times, long pid=-1)
 Process Creation time.
longlong systemStart (TimeType typ=Sec)
 Maximum processing time left for this process.
longlong upTime (TimeType typ=Hour)
 Maximum processing time left for this process.
longlong currentTime (TimeType typ=milliSec)
 Retrieve absolute system time.
longlong tickCount ()
 Retrieve the number of ticks since system startup.
long breakExecution ()
 Break the execution of the application and invoke the debugger.
long breakExecution (long pid)
 Break the execution of the application and invoke the debugger in a remote process.
StatusCode resolveEnv (const std::string &var, std::string &res, int recursions)
std::string homeDirectory ()
std::string tempDirectory ()
long adjustMemory (MemoryUnit unit, long value)
 Convert time from kByte to requested representation (Experts only).
long basePriority (InfoType fetch, long pid)
 Basic Process Information: Base priority.
long procID ()
 Basic Process Information: Process ID.
long parentID (InfoType fetch, long pid)
 Basic Process Information: Parent's process ID.
long affinityMask (InfoType fetch, long pid)
 Basic Process Information: Affinity mask.
long exitStatus (InfoType fetch, long pid)
 Basic Process Information: Exit status (does not really make sense for the running process, but for others!).
long priorityBoost (InfoType fetch, long pid)
 Basic Process Information: priority boost.
long nonPagedMemoryPeak (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Peak usage of non paged memory.
long nonPagedMemory (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Current usage of non paged memory.
long nonPagedMemoryLimit (MemoryUnit unit, InfoType fetch, long pid)
 System Process Limits: Maximum amount of non-paged memory this process is allowed to use.
long pagedMemory (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Amount of paged memory currently occupied by the process 'pid'.
long pagedMemoryPeak (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Maximum of paged memory occupied by the process 'pid'.
long pagedMemoryLimit (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Amount of paged memory that can be occupied by the process 'pid'.
long numPageFault (InfoType fetch, long pid)
 Basic Process Information: Number of page faults.
long pagefileUsage (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Current page file usage.
long pagefileUsagePeak (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Peak usage of page file.
long pagefileUsageLimit (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: Peak usage of page file.
long mappedMemory (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: priority boost.
long mappedMemoryPeak (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: priority boost.
long minMemoryLimit (MemoryUnit unit, InfoType fetch, long pid)
 System Process Limits: Minimum amount of virtual memory this process may use.
long maxMemoryLimit (MemoryUnit unit, InfoType fetch, long pid)
 System Process Limits: Maximum amount of virtual memory this process is allowed to use.
long virtualMemory (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: priority boost.
long virtualMemoryPeak (MemoryUnit unit, InfoType fetch, long pid)
 Basic Process Information: priority boost.
long virtualMemoryLimit (MemoryUnit unit, InfoType fetch, long pid)
 System Process Limits: Maximum amount of the page file this process is allowed to use.
const std::stringmoduleName ()
 Get the name of the (executable/DLL) file without file-type.
const std::stringmoduleNameFull ()
 Get the full name of the (executable/DLL) file.
const System::ModuleType moduleType ()
 Get type of the module.
void * processHandle ()
 Handle to running process.
void setModuleHandle (System::ImageHandle handle)
 Attach module handle.
System::ImageHandle moduleHandle ()
 Handle to currently executed module.
System::ImageHandle exeHandle ()
 Handle to the executable file running.
const std::stringexeName ()
 Name of the executable file running.
const std::vector< std::stringlinkedModules ()
 Vector of names of linked modules.
static void PR_compress_path (std::string &dir)
static void PR_dirname (const std::string &file_name, std::string &result)
static bool PR_absolute_path (const std::string &name)
static void PR_basename (const std::string &file_name, std::string &result)
static bool PR_test_exist (const std::string &name, std::string &real_name, PR_file_type file_type)
static void PR_scan_dir (const std::string &dir_name, std::vector< std::string > &list)
static bool PR_find (const std::string &search_base, const std::string &logical_file_prefix, const std::string &logical_file_name, PR_file_type file_type, PathResolver::SearchType search_type, std::string &result)
static bool PR_find_from_list (const std::string &logical_file_name, const std::string &search_list, PR_file_type file_type, PathResolver::SearchType search_type, std::string &result)
System::ProcessDescriptorgetProcess ()
 Retrieve Process structure.
unsigned long loadDynamicLib (const std::string &name, ImageHandle *handle)
 Load dynamic link library.
unsigned long unloadDynamicLib (ImageHandle handle)
 unload dynamic link library
unsigned long getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction)
 Get a specific function defined in the DLL.
unsigned long getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction)
 Get a specific function defined in the DLL.
unsigned long getLastError ()
 Get last system known error.
const std::string getLastErrorString ()
 Get last system error as string.
const std::string getErrorString (unsigned long error)
 Retrieve error code as string for a given error.
const std::string typeinfoName (const std::type_info &tinfo)
 Get platform independent information about the class type.
const std::string typeinfoName (const char *class_name)
const std::stringhostName ()
 Host name.
const std::stringosName ()
 OS name.
const std::stringosVersion ()
 OS version.
const std::stringmachineType ()
 Machine type.
const std::stringaccountName ()
 User login name.
long numCmdLineArgs ()
 Number of arguments passed to the commandline.
long argc ()
 Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
const std::vector< std::stringcmdLineArgs ()
 Command line arguments including executable name as arg[0] as vector of strings.
char ** argv ()
 char** command line arguments including executable name as arg[0]; You may not modify them!
const std::string getEnv (const char *var)
 get a particular environment variable
const std::vector< std::stringgetEnv ()
 get all environment variables
bool backTrace (void **addresses __attribute__((unused)), const size_t depth __attribute__((unused)))
bool getStackLevel (void *addresses __attribute__((unused)), void *&addr __attribute__((unused)), std::string &fnc __attribute__((unused)), std::string &lib __attribute__((unused)))
int setEnv (const std::string &name, const std::string &value, int overwrite)
 Set an environment variables.
longlong adjustTime (TimeType typ, longlong t)
 Convert time from OS native time to requested representation (Experts only).
longlong tickCount ()
 Retrieve the number of ticks since system startup.
longlong currentTime (TimeType typ)
 Retrieve absolute system time.
longlong systemStart (TimeType typ)
 Maximum processing time left for this process.
longlong upTime (TimeType typ)
 Maximum processing time left for this process.
longlong creationTime (TimeType typ, InfoType fetch, long pid)
 Process Creation time.
longlong remainingTime (TimeType typ, InfoType fetch, long pid)
 Maximum processing time left for this process.
longlong ellapsedTime (TimeType typ, InfoType fetch, long pid)
 Ellapsed time since start of process in milli seconds.
longlong kernelTime (TimeType typ, InfoType fetch, long pid)
 CPU kernel mode time of process in milli seconds.
longlong userTime (TimeType typ, InfoType fetch, long pid)
 CPU user mode time of process in milli seconds.
longlong cpuTime (TimeType typ, InfoType fetch, long pid)
 Consumed CPU time of process in milli seconds.


Typedef Documentation

typedef void*(*) System::Creator()

Definition of the "generic" DLL entry point function.

Definition at line 38 of file System.h.

typedef unsigned long(*) System::EntryPoint(const unsigned long iid, void **ppvObject)

Definition of the "generic" DLL entry point function.

Definition at line 36 of file System.h.

typedef void* System::ImageHandle

Definition of an image handle.

Definition at line 32 of file System.h.

typedef void* System::ImageHandle

Definition of an image handle.

Definition at line 30 of file ModuleInfo.h.

typedef struct _PEB* System::PPEB

Basic Process Information NtQueryInformationProcess using ProcessBasicInfo.

Definition at line 18 of file ProcessDescriptor.h.

typedef void* System::ProcessHandle

Definition of the process handle.

Definition at line 34 of file System.h.

typedef void* System::ProcessHandle

Definition of the process handle.

Definition at line 32 of file ModuleInfo.h.

typedef void* System::ThreadHandle

A Thread handle.

Definition at line 91 of file System.h.


Enumeration Type Documentation

enum System::InfoType

Enumeration for fetching information.

Enumerator:
NoFetch 
RemainTime 
Times 
ProcessBasics 
PriorityBoost 
Memory 
Quota 
System 
Modules 
IO 

Definition at line 18 of file SystemBase.h.

00018                   {   NoFetch, 
00019                       RemainTime, 
00020                       Times, 
00021                       ProcessBasics, 
00022                       PriorityBoost, 
00023                       Memory, 
00024                       Quota,
00025                       System, 
00026                       Modules, 
00027                       IO };

enum System::MemoryUnit

Unit of memory.

Enumerator:
Byte 
kByte 
MByte 
GByte 
TByte 
PByte 
EByte 

Definition at line 57 of file Memory.h.

00057 { Byte, kByte, MByte, GByte, TByte, PByte, EByte };

enum System::ModuleType

Enumerator:
UNKNOWN 
SHAREDLIB 
EXECUTABLE 

Definition at line 28 of file ModuleInfo.h.

enum System::PR_file_type

Enumerator:
PR_regular_file 
PR_directory 

Definition at line 23 of file PathResolver.cpp.

00024   {
00025     PR_regular_file,
00026     PR_directory
00027   } PR_file_type;

enum System::PR_search_type

Enumerator:
PR_local 
PR_recursive 

Definition at line 29 of file PathResolver.cpp.

00029              {
00030   PR_local,
00031   PR_recursive } PR_search_type;

enum System::ProcessInfoCommand

Enumerator:
ProcessBasicInformation 
ProcessQuotaLimits 
ProcessIoCounters 
ProcessVmCounters 
ProcessTimes 
ProcessBasePriority 
ProcessRaisePriority 
ProcessDebugPort 
ProcessExceptionPort 
ProcessAccessToken 
ProcessLdtInformation 
ProcessLdtSize 
ProcessDefaultHardErrorMode 
ProcessIoPortHandlers 
ProcessPooledUsageAndLimits 
ProcessWorkingSetWatch 
ProcessUserModeIOPL 
ProcessEnableAlignmentFaultFixup 
ProcessPriorityClass 
ProcessWx86Information 
ProcessHandleCount 
ProcessAffinityMask 
ProcessPriorityBoost 
MaxProcessInfoClass 
ProcessEllapsedTime 

Definition at line 21 of file ProcessDescriptor.cpp.

enum System::TimeType

Time type for conversion.

Enumerator:
Year 
Month 
Day 
Hour 
Min 
Sec 
milliSec 
microSec 
nanoSec 

Definition at line 53 of file Timing.h.


Function Documentation

const std::string& System::accountName (  ) 

User login name.

Definition at line 552 of file System.cpp.

00552                                      {
00553   static std::string account = "";
00554   if ( account == "" ) {
00555 #ifdef _WIN32
00556     char buffer[512];
00557     unsigned long buflen = sizeof(buffer);
00558     ::GetUserName(buffer, &buflen);
00559     account = buffer;
00560 #else
00561     const char* acct = ::getlogin();
00562     if ( 0 == acct ) acct = ::getenv("LOGNAME");
00563     if ( 0 == acct ) acct = ::getenv("USER");
00564     account = (acct) ? acct : "Unknown";
00565 #endif
00566   }
00567   return account;
00568 }

const std::string& System::accountName (  ) 

User login name.

Definition at line 552 of file System.cpp.

00552                                      {
00553   static std::string account = "";
00554   if ( account == "" ) {
00555 #ifdef _WIN32
00556     char buffer[512];
00557     unsigned long buflen = sizeof(buffer);
00558     ::GetUserName(buffer, &buflen);
00559     account = buffer;
00560 #else
00561     const char* acct = ::getlogin();
00562     if ( 0 == acct ) acct = ::getenv("LOGNAME");
00563     if ( 0 == acct ) acct = ::getenv("USER");
00564     account = (acct) ? acct : "Unknown";
00565 #endif
00566   }
00567   return account;
00568 }

long System::adjustMemory ( MemoryUnit  unit,
long  value 
)

Convert time from kByte to requested representation (Experts only).

Definition at line 35 of file Memory.cpp.

References Byte, EByte, GByte, kByte, MByte, PByte, and TByte.

Referenced by mappedMemory(), mappedMemoryPeak(), maxMemoryLimit(), minMemoryLimit(), nonPagedMemory(), nonPagedMemoryLimit(), nonPagedMemoryPeak(), pagedMemory(), pagedMemoryLimit(), pagedMemoryPeak(), pagefileUsage(), pagefileUsageLimit(), pagefileUsagePeak(), virtualMemory(), virtualMemoryLimit(), and virtualMemoryPeak().

00035                                                           {
00036   if ( value != -1 )    {
00037     switch ( unit )   {
00038     case Byte:      value =       value;    break;
00039     case kByte:     value =       value/1024;    break;
00040     case MByte:     value =      (value/1024)/1024;    break;
00041     case GByte:     value =     ((value/1024)/1024)/1024;    break;
00042     case TByte:     value =    (((value/1024)/1024)/1024)/1024;    break;
00043     case PByte:     value =   ((((value/1024)/1024)/1024)/1024)/1024;    break;
00044     case EByte:     value =  (((((value/1024)/1024)/1024)/1024)/1024)/1024;    break;
00045     default:        value =  -1;    break;
00046     }
00047   }
00048   return value;
00049 }

long System::adjustMemory ( MemoryUnit  typ,
long  value 
)

Convert time from kByte to requested representation (Experts only).

Definition at line 35 of file Memory.cpp.

References Byte, EByte, GByte, kByte, MByte, PByte, and TByte.

Referenced by mappedMemory(), mappedMemoryPeak(), maxMemoryLimit(), minMemoryLimit(), nonPagedMemory(), nonPagedMemoryLimit(), nonPagedMemoryPeak(), pagedMemory(), pagedMemoryLimit(), pagedMemoryPeak(), pagefileUsage(), pagefileUsageLimit(), pagefileUsagePeak(), virtualMemory(), virtualMemoryLimit(), and virtualMemoryPeak().

00035                                                           {
00036   if ( value != -1 )    {
00037     switch ( unit )   {
00038     case Byte:      value =       value;    break;
00039     case kByte:     value =       value/1024;    break;
00040     case MByte:     value =      (value/1024)/1024;    break;
00041     case GByte:     value =     ((value/1024)/1024)/1024;    break;
00042     case TByte:     value =    (((value/1024)/1024)/1024)/1024;    break;
00043     case PByte:     value =   ((((value/1024)/1024)/1024)/1024)/1024;    break;
00044     case EByte:     value =  (((((value/1024)/1024)/1024)/1024)/1024)/1024;    break;
00045     default:        value =  -1;    break;
00046     }
00047   }
00048   return value;
00049 }

longlong System::adjustTime ( TimeType  typ,
longlong  t 
)

Convert time from OS native time to requested representation (Experts only).

unfortunately "-ansi" flag turn off teh correct definition of CLK_TCK and forces it to be equal CLOCKS_PER_SEC, it is wrong!

t /= CLOCKS_PER_SEC; // needs division by clock tick unit

Definition at line 38 of file Timing.cpp.

References Day, Hour, microSec, milliSec, Min, Month, nanoSec, Sec, and Year.

Referenced by cpuTime(), creationTime(), currentTime(), ellapsedTime(), kernelTime(), remainingTime(), systemStart(), upTime(), and userTime().

00038                                                       {
00039   if ( t != -1 )   {
00040 #ifndef _WIN32
00042     //  t /= CLK_TCK ;     // needs division by clock tick unit
00046 
00048 #endif
00049     switch( typ )   {
00050     case Year:      t /= 365;
00051     case Day:       t /= 24;
00052     case Hour:      t /= 60;
00053     case Min:       t /= 60;
00054     case Sec:       t /= 1000;
00055     case milliSec:  t /= 1000;
00056     case microSec:  t /= 10;                    break;
00057     case nanoSec:   t *= 100;                   break;
00058     case Month:     t /= (12*24*3600);
00059                     t /= 10000000;              break;
00060     default:                                    break;
00061     }
00062   }
00063   return t;
00064 }

longlong System::adjustTime ( TimeType  typ,
longlong  timevalue 
)

Convert time from OS native time to requested representation (Experts only).

unfortunately "-ansi" flag turn off teh correct definition of CLK_TCK and forces it to be equal CLOCKS_PER_SEC, it is wrong!

t /= CLOCKS_PER_SEC; // needs division by clock tick unit

Definition at line 38 of file Timing.cpp.

References Day, Hour, microSec, milliSec, Min, Month, nanoSec, Sec, and Year.

Referenced by cpuTime(), creationTime(), currentTime(), ellapsedTime(), kernelTime(), remainingTime(), systemStart(), upTime(), and userTime().

00038                                                       {
00039   if ( t != -1 )   {
00040 #ifndef _WIN32
00042     //  t /= CLK_TCK ;     // needs division by clock tick unit
00046 
00048 #endif
00049     switch( typ )   {
00050     case Year:      t /= 365;
00051     case Day:       t /= 24;
00052     case Hour:      t /= 60;
00053     case Min:       t /= 60;
00054     case Sec:       t /= 1000;
00055     case milliSec:  t /= 1000;
00056     case microSec:  t /= 10;                    break;
00057     case nanoSec:   t *= 100;                   break;
00058     case Month:     t /= (12*24*3600);
00059                     t /= 10000000;              break;
00060     default:                                    break;
00061     }
00062   }
00063   return t;
00064 }

long System::affinityMask ( InfoType  fetch,
long  pid 
)

Basic Process Information: Affinity mask.

Definition at line 74 of file Memory.cpp.

References System::PROCESS_BASIC_INFORMATION::AffinityMask, getProcess(), NoFetch, and ProcessBasics.

00074                                                     {
00075   PROCESS_BASIC_INFORMATION info;
00076   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00077     return info.AffinityMask;
00078   return 0;
00079 }

long System::affinityMask ( InfoType  fetch = ProcessBasics,
long  pid = -1 
)

Basic Process Information: Affinity mask.

Definition at line 74 of file Memory.cpp.

References System::PROCESS_BASIC_INFORMATION::AffinityMask, getProcess(), NoFetch, and ProcessBasics.

00074                                                     {
00075   PROCESS_BASIC_INFORMATION info;
00076   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00077     return info.AffinityMask;
00078   return 0;
00079 }

long System::argc (  ) 

Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...

Definition at line 576 of file System.cpp.

References cmdLineArgs().

00576                      {
00577   return cmdLineArgs().size();
00578 }

long System::argc (  ) 

Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...

Definition at line 576 of file System.cpp.

References cmdLineArgs().

00576                      {
00577   return cmdLineArgs().size();
00578 }

char** System::argv (  ) 

char** command line arguments including executable name as arg[0]; You may not modify them!

added by I.B.

Definition at line 638 of file System.cpp.

References cmdLineArgs(), and s_argvChars.

Referenced by apmon_mon_utils::getChildren(), ProcUtils::getNetstatInfo(), ProcUtils::getProcesses(), apmon_mon_utils::readJobDiskUsage(), and apmon_mon_utils::readJobInfo().

00638                        {
00640   if( s_argvChars.empty() ) { cmdLineArgs(); }  
00641 
00642   // We rely here on the fact that a vector's allocation table is contiguous
00643   return (char**)&s_argvChars[0];
00644 }

char** System::argv (  ) 

char** command line arguments including executable name as arg[0]; You may not modify them!

added by I.B.

Definition at line 638 of file System.cpp.

References cmdLineArgs(), and s_argvChars.

Referenced by apmon_mon_utils::getChildren(), ProcUtils::getNetstatInfo(), ProcUtils::getProcesses(), apmon_mon_utils::readJobDiskUsage(), and apmon_mon_utils::readJobInfo().

00638                        {
00640   if( s_argvChars.empty() ) { cmdLineArgs(); }  
00641 
00642   // We rely here on the fact that a vector's allocation table is contiguous
00643   return (char**)&s_argvChars[0];
00644 }

bool System::backTrace ( void **addresses   __attribute__((unused)),
const size_t depth   __attribute__((unused)) 
)

Definition at line 676 of file System.cpp.

00678 {
00679 
00680 #ifdef __linux
00681      
00682   if ( backtrace( addresses, depth ) > 0 ) {
00683     return true ;
00684   } else {
00685     return false ;
00686   }
00687   
00688 #else // windows and osx parts not implemented
00689   return false ;
00690 #endif
00691 
00692 }

bool System::backTrace ( void **  addresses,
const size_t  depth 
)

Referenced by IssueLogger::getTraceBack(), and StatusCode::~StatusCode().

long System::basePriority ( InfoType  fetch,
long  pid 
)

Basic Process Information: Base priority.

Definition at line 52 of file Memory.cpp.

References System::PROCESS_BASIC_INFORMATION::BasePriority, getProcess(), NoFetch, and ProcessBasics.

00052                                                     {
00053   PROCESS_BASIC_INFORMATION info;
00054   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00055     return info.BasePriority;
00056   return 0;
00057 }

long System::basePriority ( InfoType  fetch = ProcessBasics,
long  pid = -1 
)

Basic Process Information: Base priority.

Definition at line 52 of file Memory.cpp.

References System::PROCESS_BASIC_INFORMATION::BasePriority, getProcess(), NoFetch, and ProcessBasics.

00052                                                     {
00053   PROCESS_BASIC_INFORMATION info;
00054   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00055     return info.BasePriority;
00056   return 0;
00057 }

long System::breakExecution ( long  pid  ) 

Break the execution of the application and invoke the debugger in a remote process.

Definition at line 44 of file Debugger.cpp.

00044                                       {
00045 #ifdef _WIN32
00046   long result = 0;
00047   if ( pid == Win::_getpid() )    {
00048     _asm int 3
00049     return 1;
00050   }
00051   else    {
00052     Win::LPTHREAD_START_ROUTINE fun;
00053     Win::HANDLE th, ph;
00054     Win::HINSTANCE mh;
00055     Win::DWORD id;
00056     mh = Win::LoadLibrary( "Kernel32" );
00057     if ( 0 != mh )    {
00058       fun = (Win::LPTHREAD_START_ROUTINE)Win::GetProcAddress(mh, "DebugBreak");
00059       if ( 0 != fun )   {
00060         ph = Win::OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
00061         if ( 0 != ph )      {
00062           th = Win::CreateRemoteThread(ph,NULL,0,fun,0,0,&id);
00063           if ( 0 != th )   {
00064             Win::CloseHandle(th);
00065             result = 1;
00066           }
00067           Win::CloseHandle(ph);
00068         }
00069       }
00070       Win::FreeLibrary(mh);
00071     }
00072   }
00073   if ( result != 1 ) result = Win::GetLastError();
00074   return result;
00075 #else
00076   // I have no clu how to do this in linux
00077   return pid;
00078 #endif
00079 }

long System::breakExecution (  ) 

Break the execution of the application and invoke the debugger.

Definition at line 33 of file Debugger.cpp.

00033                               {
00034 #ifdef _WIN32
00035   _asm int 3
00036   return 1;
00037 #else
00038   // I have no clu how to do this in linux
00039   return 0;
00040 #endif
00041 }

long System::breakExecution ( long  pid  ) 

Break the execution of the application and invoke the debugger in a remote process.

Definition at line 44 of file Debugger.cpp.

00044                                       {
00045 #ifdef _WIN32
00046   long result = 0;
00047   if ( pid == Win::_getpid() )    {
00048     _asm int 3
00049     return 1;
00050   }
00051   else    {
00052     Win::LPTHREAD_START_ROUTINE fun;
00053     Win::HANDLE th, ph;
00054     Win::HINSTANCE mh;
00055     Win::DWORD id;
00056     mh = Win::LoadLibrary( "Kernel32" );
00057     if ( 0 != mh )    {
00058       fun = (Win::LPTHREAD_START_ROUTINE)Win::GetProcAddress(mh, "DebugBreak");
00059       if ( 0 != fun )   {
00060         ph = Win::OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
00061         if ( 0 != ph )      {
00062           th = Win::CreateRemoteThread(ph,NULL,0,fun,0,0,&id);
00063           if ( 0 != th )   {
00064             Win::CloseHandle(th);
00065             result = 1;
00066           }
00067           Win::CloseHandle(ph);
00068         }
00069       }
00070       Win::FreeLibrary(mh);
00071     }
00072   }
00073   if ( result != 1 ) result = Win::GetLastError();
00074   return result;
00075 #else
00076   // I have no clu how to do this in linux
00077   return pid;
00078 #endif
00079 }

long System::breakExecution (  ) 

Break the execution of the application and invoke the debugger.

Definition at line 33 of file Debugger.cpp.

Referenced by Gaudi::IODataManager::error().

00033                               {
00034 #ifdef _WIN32
00035   _asm int 3
00036   return 1;
00037 #else
00038   // I have no clu how to do this in linux
00039   return 0;
00040 #endif
00041 }

const std::vector<std::string> System::cmdLineArgs (  ) 

Command line arguments including executable name as arg[0] as vector of strings.

Definition at line 581 of file System.cpp.

References std::cout, std::endl(), exeName(), s_argvChars, and s_argvStrings.

Referenced by argc(), argv(), and numCmdLineArgs().

00581                                                   {
00582   if ( s_argvChars.size() == 0 )    {
00583     char exe[1024];
00584 #ifdef _WIN32
00585     // For compatibility with UNIX we CANNOT use strtok!
00586     // If we would use strtok, options like -g="My world" at
00587     // the command line level would result on NT in TWO options 
00588     // instead in one as in UNIX.
00589     char *next, *tmp1, *tmp2;
00590     for(LPTSTR cmd = ::GetCommandLine(); *cmd; cmd=next)   {
00591       memset(exe,0,sizeof(exe));
00592       while ( *cmd == ' ' ) cmd++;
00593       next=::strchr(cmd,' ');
00594       if ( !next ) next = cmd + strlen(cmd);
00595       if ( (tmp1=::strchr(cmd,'\"')) > 0 && tmp1 < next )  {
00596         tmp2 = ::strchr(++tmp1,'\"');
00597         if ( tmp2 > 0 )   {
00598           next = ++tmp2;
00599           if ( cmd < tmp1 ) strncpy(exe, cmd, tmp1-cmd-1);
00600           strncpy(&exe[strlen(exe)], tmp1, tmp2-tmp1-1);
00601         }
00602         else    {
00603           std::cout << "Mismatched \" in command line arguments" << std::endl;
00604           s_argvChars.erase(s_argvChars.begin(), s_argvChars.end());
00605           s_argvStrings.erase(s_argvStrings.begin(), s_argvStrings.end());
00606           return s_argvStrings;
00607         }
00608       }
00609       else    {
00610         strncpy(exe, cmd, next-cmd);
00611       }
00612       s_argvStrings.push_back(exe);
00613       s_argvChars.push_back( s_argvStrings.back().c_str());
00614     }
00615 #elif defined(linux) || defined(__APPLE__)
00616     sprintf(exe, "/proc/%d/cmdline", ::getpid());
00617     FILE *cmdLine = ::fopen(exe,"r");
00618     char cmd[1024];
00619     if ( cmdLine )   {
00620       long len = fread(cmd, sizeof(char), sizeof(cmd), cmdLine);
00621       if ( len > 0 )   {
00622         cmd[len] = 0;
00623         for ( char* token = cmd; token-cmd < len; token += strlen(token)+1 )  {
00624           s_argvStrings.push_back(token);
00625           s_argvChars.push_back( s_argvStrings.back().c_str());
00626         }
00627         s_argvStrings[0] = exeName();
00628         s_argvChars[0]   = s_argvStrings[0].c_str();
00629       }
00630     }
00631     ::fclose(cmdLine);
00632 #endif
00633   }
00634   return s_argvStrings;
00635 }

const std::vector<std::string> System::cmdLineArgs (  ) 

Command line arguments including executable name as arg[0] as vector of strings.

Definition at line 581 of file System.cpp.

References std::cout, std::endl(), exeName(), s_argvChars, and s_argvStrings.

Referenced by argc(), argv(), and numCmdLineArgs().

00581                                                   {
00582   if ( s_argvChars.size() == 0 )    {
00583     char exe[1024];
00584 #ifdef _WIN32
00585     // For compatibility with UNIX we CANNOT use strtok!
00586     // If we would use strtok, options like -g="My world" at
00587     // the command line level would result on NT in TWO options 
00588     // instead in one as in UNIX.
00589     char *next, *tmp1, *tmp2;
00590     for(LPTSTR cmd = ::GetCommandLine(); *cmd; cmd=next)   {
00591       memset(exe,0,sizeof(exe));
00592       while ( *cmd == ' ' ) cmd++;
00593       next=::strchr(cmd,' ');
00594       if ( !next ) next = cmd + strlen(cmd);
00595       if ( (tmp1=::strchr(cmd,'\"')) > 0 && tmp1 < next )  {
00596         tmp2 = ::strchr(++tmp1,'\"');
00597         if ( tmp2 > 0 )   {
00598           next = ++tmp2;
00599           if ( cmd < tmp1 ) strncpy(exe, cmd, tmp1-cmd-1);
00600           strncpy(&exe[strlen(exe)], tmp1, tmp2-tmp1-1);
00601         }
00602         else    {
00603           std::cout << "Mismatched \" in command line arguments" << std::endl;
00604           s_argvChars.erase(s_argvChars.begin(), s_argvChars.end());
00605           s_argvStrings.erase(s_argvStrings.begin(), s_argvStrings.end());
00606           return s_argvStrings;
00607         }
00608       }
00609       else    {
00610         strncpy(exe, cmd, next-cmd);
00611       }
00612       s_argvStrings.push_back(exe);
00613       s_argvChars.push_back( s_argvStrings.back().c_str());
00614     }
00615 #elif defined(linux) || defined(__APPLE__)
00616     sprintf(exe, "/proc/%d/cmdline", ::getpid());
00617     FILE *cmdLine = ::fopen(exe,"r");
00618     char cmd[1024];
00619     if ( cmdLine )   {
00620       long len = fread(cmd, sizeof(char), sizeof(cmd), cmdLine);
00621       if ( len > 0 )   {
00622         cmd[len] = 0;
00623         for ( char* token = cmd; token-cmd < len; token += strlen(token)+1 )  {
00624           s_argvStrings.push_back(token);
00625           s_argvChars.push_back( s_argvStrings.back().c_str());
00626         }
00627         s_argvStrings[0] = exeName();
00628         s_argvChars[0]   = s_argvStrings[0].c_str();
00629       }
00630     }
00631     ::fclose(cmdLine);
00632 #endif
00633   }
00634   return s_argvStrings;
00635 }

longlong System::cpuTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

Consumed CPU time of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 170 of file Timing.cpp.

References adjustTime(), getProcess(), System::KERNEL_USER_TIMES::KernelTime, NoFetch, and System::KERNEL_USER_TIMES::UserTime.

Referenced by TimerForSequencer::start(), and TimerForSequencer::stop().

00170                                                                {
00171   longlong cputime = 0;
00172   KERNEL_USER_TIMES info;
00173   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00174     cputime = adjustTime(typ, info.KernelTime+info.UserTime );
00175   }
00176   return cputime;
00177 }

longlong System::cpuTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

Consumed CPU time of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 170 of file Timing.cpp.

References adjustTime(), getProcess(), System::KERNEL_USER_TIMES::KernelTime, NoFetch, and System::KERNEL_USER_TIMES::UserTime.

Referenced by TimerForSequencer::start(), and TimerForSequencer::stop().

00170                                                                {
00171   longlong cputime = 0;
00172   KERNEL_USER_TIMES info;
00173   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00174     cputime = adjustTime(typ, info.KernelTime+info.UserTime );
00175   }
00176   return cputime;
00177 }

longlong System::creationTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

Process Creation time.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 116 of file Timing.cpp.

References adjustTime(), System::KERNEL_USER_TIMES::CreateTime, getProcess(), NoFetch, and UNIX_BASE_TIME.

00116                                                                       {
00117   longlong created = 0;
00118   KERNEL_USER_TIMES info;
00119   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00120     created = adjustTime(typ, info.CreateTime-UNIX_BASE_TIME);
00121   }
00122   return created;
00123 }

longlong System::creationTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

Process Creation time.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 116 of file Timing.cpp.

References adjustTime(), System::KERNEL_USER_TIMES::CreateTime, getProcess(), NoFetch, and UNIX_BASE_TIME.

00116                                                                       {
00117   longlong created = 0;
00118   KERNEL_USER_TIMES info;
00119   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00120     created = adjustTime(typ, info.CreateTime-UNIX_BASE_TIME);
00121   }
00122   return created;
00123 }

longlong System::currentTime ( TimeType  typ = milliSec  ) 

Retrieve absolute system time.

Parameters:
typ Indicator or the unit the time will be returned.
Returns:
Requested value in the indicated units.

Definition at line 81 of file Timing.cpp.

References adjustTime(), and UNIX_BASE_TIME.

Referenced by ellapsedTime(), formattedTime(), TimerForSequencer::start(), TimerForSequencer::stop(), systemStart(), and upTime().

00081                                             {
00082   longlong current = 0;
00083 #ifdef _WIN32
00084   ::GetSystemTimeAsFileTime((FILETIME*)&current);
00085   current -= UNIX_BASE_TIME;
00086 #else
00087   struct timeval tv;
00088   struct timezone tz;
00089   ::gettimeofday(&tv, &tz);
00090   current  = tv.tv_sec;
00091   current *= 1000000;
00092   current += tv.tv_usec;
00093   current *= 10;
00094 #endif
00095   return adjustTime(typ, current);
00096 }

longlong System::currentTime ( TimeType  typ = milliSec  ) 

Retrieve absolute system time.

Parameters:
typ Indicator or the unit the time will be returned.
Returns:
Requested value in the indicated units.

Definition at line 81 of file Timing.cpp.

References adjustTime(), and UNIX_BASE_TIME.

Referenced by ellapsedTime(), formattedTime(), TimerForSequencer::start(), TimerForSequencer::stop(), systemStart(), and upTime().

00081                                             {
00082   longlong current = 0;
00083 #ifdef _WIN32
00084   ::GetSystemTimeAsFileTime((FILETIME*)&current);
00085   current -= UNIX_BASE_TIME;
00086 #else
00087   struct timeval tv;
00088   struct timezone tz;
00089   ::gettimeofday(&tv, &tz);
00090   current  = tv.tv_sec;
00091   current *= 1000000;
00092   current += tv.tv_usec;
00093   current *= 10;
00094 #endif
00095   return adjustTime(typ, current);
00096 }

longlong System::ellapsedTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

Ellapsed time since start of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
timevalue Time value to be converted.
Returns:
Requested value in the indicated units.

Definition at line 141 of file Timing.cpp.

References adjustTime(), System::KERNEL_USER_TIMES::CreateTime, currentTime(), getProcess(), microSec, System::ProcessDescriptor::query(), and UNIX_BASE_TIME.

Referenced by ChronoEntity::start(), and ChronoEntity::stop().

00141                                                                     {
00142   KERNEL_USER_TIMES info;
00143   longlong ellapsed = currentTime(microSec)*10;
00144   getProcess()->query(pid, fetch, &info);
00145   ellapsed = adjustTime(typ, ellapsed+UNIX_BASE_TIME-info.CreateTime);
00146   return ellapsed;
00147 }

longlong System::ellapsedTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

Ellapsed time since start of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
timevalue Time value to be converted.
Returns:
Requested value in the indicated units.

Definition at line 141 of file Timing.cpp.

References adjustTime(), System::KERNEL_USER_TIMES::CreateTime, currentTime(), getProcess(), microSec, System::ProcessDescriptor::query(), and UNIX_BASE_TIME.

Referenced by ChronoEntity::start(), and ChronoEntity::stop().

00141                                                                     {
00142   KERNEL_USER_TIMES info;
00143   longlong ellapsed = currentTime(microSec)*10;
00144   getProcess()->query(pid, fetch, &info);
00145   ellapsed = adjustTime(typ, ellapsed+UNIX_BASE_TIME-info.CreateTime);
00146   return ellapsed;
00147 }

System::ImageHandle System::exeHandle (  ) 

Handle to the executable file running.

Definition at line 156 of file ModuleInfo.cpp.

References ModuleHandle, and processHandle().

Referenced by exeName().

00156                                        {
00157 #ifdef _WIN32
00158   if ( processHandle() )    {
00159     static HINSTANCE handle = 0;
00160     DWORD   cbNeeded;
00161     if ( 0 == handle && _psApi.isValid() )    {
00162       if ( _psApi.EnumProcessModules( processHandle(), &handle, sizeof(ModuleHandle), &cbNeeded) )   {
00163       }
00164     }
00165     return handle;
00166   }
00167 #elif defined(linux) || defined(__APPLE__)
00168   // This does NOT work!
00169   static Dl_info infoBuf, *info = &infoBuf;
00170   if ( 0 == info ) {
00171     void* handle = ::dlopen(0, RTLD_LAZY);
00172     //printf("Exe handle:%X\n", handle);
00173     if ( 0 != handle ) {
00174       void* func = ::dlsym(handle, "main");
00175       //printf("Exe:Func handle:%X\n", func);
00176       if ( 0 != func ) {
00177         if ( 0 != ::dladdr(func, &infoBuf) ) {
00178                 //std::cout << "All OK" << std::endl;
00179           info = &infoBuf;
00180         }
00181       }
00182     }
00183   }
00184   return info;
00185 #elif __hpux
00186   // Don't know how to solve this .....
00187 #endif
00188   return 0;
00189 }

ImageHandle System::exeHandle (  ) 

Handle to the executable file running.

Definition at line 156 of file ModuleInfo.cpp.

References ModuleHandle, and processHandle().

Referenced by exeName().

00156                                        {
00157 #ifdef _WIN32
00158   if ( processHandle() )    {
00159     static HINSTANCE handle = 0;
00160     DWORD   cbNeeded;
00161     if ( 0 == handle && _psApi.isValid() )    {
00162       if ( _psApi.EnumProcessModules( processHandle(), &handle, sizeof(ModuleHandle), &cbNeeded) )   {
00163       }
00164     }
00165     return handle;
00166   }
00167 #elif defined(linux) || defined(__APPLE__)
00168   // This does NOT work!
00169   static Dl_info infoBuf, *info = &infoBuf;
00170   if ( 0 == info ) {
00171     void* handle = ::dlopen(0, RTLD_LAZY);
00172     //printf("Exe handle:%X\n", handle);
00173     if ( 0 != handle ) {
00174       void* func = ::dlsym(handle, "main");
00175       //printf("Exe:Func handle:%X\n", func);
00176       if ( 0 != func ) {
00177         if ( 0 != ::dladdr(func, &infoBuf) ) {
00178                 //std::cout << "All OK" << std::endl;
00179           info = &infoBuf;
00180         }
00181       }
00182     }
00183   }
00184   return info;
00185 #elif __hpux
00186   // Don't know how to solve this .....
00187 #endif
00188   return 0;
00189 }

const std::string& System::exeName (  ) 

Name of the executable file running.

Definition at line 191 of file ModuleInfo.cpp.

References exeHandle(), std::basic_string< _CharT, _Traits, _Alloc >::length(), name, and processHandle().

Referenced by cmdLineArgs(), and doLoad().

00191                                     {
00192   static std::string module("");
00193   if ( module.length() == 0 )    {
00194     char name[512] = {"Unknown.module"};
00195     name[0] = 0;
00196 #ifdef _WIN32
00197     if ( _psApi.isValid() && processHandle() )   {
00198       _psApi.GetModuleFileNameExA( processHandle(), (HINSTANCE)exeHandle(), name,sizeof(name) );
00199     }
00200 #elif defined(linux) || defined(__APPLE__)
00201     char cmd[512];
00202     ::sprintf(cmd, "/proc/%d/exe", ::getpid());
00203     module = "Unknown";
00204     ::readlink(cmd, name, sizeof(name));
00205 #elif __hpux
00206     ::realpath(((HMODULE*)exeHandle())->dsc.filename, name);
00207 #endif
00208     module = name;
00209   }
00210   return module;
00211 }

const std::string& System::exeName (  ) 

Name of the executable file running.

Definition at line 191 of file ModuleInfo.cpp.

References exeHandle(), std::basic_string< _CharT, _Traits, _Alloc >::length(), name, and processHandle().

Referenced by cmdLineArgs(), and doLoad().

00191                                     {
00192   static std::string module("");
00193   if ( module.length() == 0 )    {
00194     char name[512] = {"Unknown.module"};
00195     name[0] = 0;
00196 #ifdef _WIN32
00197     if ( _psApi.isValid() && processHandle() )   {
00198       _psApi.GetModuleFileNameExA( processHandle(), (HINSTANCE)exeHandle(), name,sizeof(name) );
00199     }
00200 #elif defined(linux) || defined(__APPLE__)
00201     char cmd[512];
00202     ::sprintf(cmd, "/proc/%d/exe", ::getpid());
00203     module = "Unknown";
00204     ::readlink(cmd, name, sizeof(name));
00205 #elif __hpux
00206     ::realpath(((HMODULE*)exeHandle())->dsc.filename, name);
00207 #endif
00208     module = name;
00209   }
00210   return module;
00211 }

long System::exitStatus ( InfoType  fetch,
long  pid 
)

Basic Process Information: Exit status (does not really make sense for the running process, but for others!).

Definition at line 82 of file Memory.cpp.

References System::PROCESS_BASIC_INFORMATION::ExitStatus, getProcess(), NoFetch, and ProcessBasics.

00082                                                   {
00083   PROCESS_BASIC_INFORMATION info;
00084   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00085     return info.ExitStatus;
00086   return -2;
00087 }

long System::exitStatus ( InfoType  fetch = ProcessBasics,
long  pid = -1 
)

Basic Process Information: Exit status (does not really make sense for the running process, but for others!).

Definition at line 82 of file Memory.cpp.

References System::PROCESS_BASIC_INFORMATION::ExitStatus, getProcess(), NoFetch, and ProcessBasics.

00082                                                   {
00083   PROCESS_BASIC_INFORMATION info;
00084   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00085     return info.ExitStatus;
00086   return -2;
00087 }

const std::vector<std::string> System::getEnv (  ) 

get all environment variables

Definition at line 661 of file System.cpp.

References std::vector< _Tp, _Alloc >::push_back().

00661                                           {
00662 #if defined(_WIN32)
00663 #  define environ _environ
00664 #elif defined(linux)
00665   extern char **environ;
00666 #elif defined(__APPLE__)
00667   static char **environ = *_NSGetEnviron();
00668 #endif
00669   std::vector<std::string> vars;
00670   for (int i=0; environ[i] != 0; ++i) {
00671     vars.push_back(environ[i]);
00672   }
00673   return vars;
00674 }

const std::string System::getEnv ( const char *  var  ) 

get a particular environment variable

Definition at line 647 of file System.cpp.

00647                                               {
00648   char* env;
00649   if  ( (env = getenv(var)) != 0 ) {
00650     return env;
00651   } else {
00652     return "UNKNOWN";
00653   }
00654 }

const std::vector<std::string> System::getEnv (  ) 

get all environment variables

Definition at line 661 of file System.cpp.

00661                                           {
00662 #if defined(_WIN32)
00663 #  define environ _environ
00664 #elif defined(linux)
00665   extern char **environ;
00666 #elif defined(__APPLE__)
00667   static char **environ = *_NSGetEnviron();
00668 #endif
00669   std::vector<std::string> vars;
00670   for (int i=0; environ[i] != 0; ++i) {
00671     vars.push_back(environ[i]);
00672   }
00673   return vars;
00674 }

const std::string System::getEnv ( const char *  var  ) 

get a particular environment variable

Definition at line 647 of file System.cpp.

Referenced by ApplicationMgr::configure(), HistorySvc::HistorySvc(), JobHistory::JobHistory(), and JobOptionsSvc::JobOptionsSvc().

00647                                               {
00648   char* env;
00649   if  ( (env = getenv(var)) != 0 ) {
00650     return env;
00651   } else {
00652     return "UNKNOWN";
00653   }
00654 }

const std::string System::getErrorString ( unsigned long  error  ) 

Retrieve error code as string for a given error.

Definition at line 244 of file System.cpp.

Referenced by getLastErrorString().

00244                                                              {
00245   std::string errString =  "";
00246 #ifdef _WIN32
00247   LPVOID lpMessageBuffer;
00248   ::FormatMessage( 
00249     FORMAT_MESSAGE_ALLOCATE_BUFFER |  FORMAT_MESSAGE_FROM_SYSTEM,
00250     NULL,
00251     error,
00252     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00253     (LPTSTR) &lpMessageBuffer,
00254     0,
00255     NULL );
00256   errString = (const char*)lpMessageBuffer;
00257   // Free the buffer allocated by the system
00258   ::LocalFree( lpMessageBuffer ); 
00259 #else
00260   char *cerrString(0);
00261   // Remember: for linux dl* routines must be handled differently!
00262   if ( error == 0xAFFEDEAD ) {
00263     cerrString = (char*)::dlerror();
00264     if ( 0 == cerrString ) {
00265       cerrString = ::strerror(error);
00266     }
00267     if ( 0 == cerrString ) {
00268       cerrString = (char *)"Unknown error. No information found in strerror()!";
00269     }
00270     else {
00271       errString = std::string(cerrString);
00272     }
00273     errno = 0;
00274   }
00275   else    {
00276     cerrString = ::strerror(error);
00277     errString = std::string(cerrString);
00278   }
00279 #endif
00280   return errString;
00281 }

const std::string System::getErrorString ( unsigned long  error  ) 

Retrieve error code as string for a given error.

Definition at line 244 of file System.cpp.

Referenced by getLastErrorString().

00244                                                              {
00245   std::string errString =  "";
00246 #ifdef _WIN32
00247   LPVOID lpMessageBuffer;
00248   ::FormatMessage( 
00249     FORMAT_MESSAGE_ALLOCATE_BUFFER |  FORMAT_MESSAGE_FROM_SYSTEM,
00250     NULL,
00251     error,
00252     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language
00253     (LPTSTR) &lpMessageBuffer,
00254     0,
00255     NULL );
00256   errString = (const char*)lpMessageBuffer;
00257   // Free the buffer allocated by the system
00258   ::LocalFree( lpMessageBuffer ); 
00259 #else
00260   char *cerrString(0);
00261   // Remember: for linux dl* routines must be handled differently!
00262   if ( error == 0xAFFEDEAD ) {
00263     cerrString = (char*)::dlerror();
00264     if ( 0 == cerrString ) {
00265       cerrString = ::strerror(error);
00266     }
00267     if ( 0 == cerrString ) {
00268       cerrString = (char *)"Unknown error. No information found in strerror()!";
00269     }
00270     else {
00271       errString = std::string(cerrString);
00272     }
00273     errno = 0;
00274   }
00275   else    {
00276     cerrString = ::strerror(error);
00277     errString = std::string(cerrString);
00278   }
00279 #endif
00280   return errString;
00281 }

unsigned long System::getLastError (  ) 

Get last system known error.

Definition at line 229 of file System.cpp.

Referenced by doLoad(), getLastErrorString(), getProcedureByName(), and unloadDynamicLib().

00229                                       {
00230 #ifdef _WIN32
00231   return ::GetLastError();
00232 #else
00233   return static_cast<unsigned long>(errno);
00234 #endif
00235 }

unsigned long System::getLastError (  ) 

Get last system known error.

Definition at line 229 of file System.cpp.

Referenced by doLoad(), getLastErrorString(), getProcedureByName(), and unloadDynamicLib().

00229                                       {
00230 #ifdef _WIN32
00231   return ::GetLastError();
00232 #else
00233   return static_cast<unsigned long>(errno);
00234 #endif
00235 }

const std::string System::getLastErrorString (  ) 

Get last system error as string.

Definition at line 238 of file System.cpp.

References getErrorString(), and getLastError().

Referenced by Gaudi::createInstance(), configGenerator::genConfig(), getProcedureByName(), PoolDbCacheSvc::loadDictionary(), and DLLClassManager::loadModule().

00238                                               {
00239   const std::string errString = getErrorString(getLastError());
00240   return errString;
00241 }

const std::string System::getLastErrorString (  ) 

Get last system error as string.

Definition at line 238 of file System.cpp.

References getErrorString(), and getLastError().

Referenced by Gaudi::createInstance(), configGenerator::genConfig(), getProcedureByName(), PoolDbCacheSvc::loadDictionary(), and DLLClassManager::loadModule().

00238                                               {
00239   const std::string errString = getErrorString(getLastError());
00240   return errString;
00241 }

unsigned long System::getProcedureByName ( ImageHandle  handle,
const std::string name,
Creator *  pFunction 
)

Get a specific function defined in the DLL.

Definition at line 224 of file System.cpp.

References getProcedureByName(), and name.

00224                                                                                                          {
00225   return getProcedureByName(handle, name, (EntryPoint*)pFunction);
00226 }

unsigned long System::getProcedureByName ( ImageHandle  handle,
const std::string name,
EntryPoint *  pFunction 
)

Get a specific function defined in the DLL.

Definition at line 178 of file System.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::cout, std::basic_string< _CharT, _Traits, _Alloc >::data(), std::endl(), getLastError(), getLastErrorString(), std::basic_string< _CharT, _Traits, _Alloc >::length(), and name.

00178                                                                                                             {
00179 #ifdef _WIN32
00180   *pFunction = (EntryPoint)::GetProcAddress((HINSTANCE)handle, name.data());
00181   if ( 0 == *pFunction )    {
00182     return System::getLastError();
00183   }
00184   return 1;
00185 #elif defined(linux)
00186   *pFunction = (EntryPoint)::dlsym(handle, name.c_str());
00187   if ( 0 == *pFunction )    {
00188     errno = 0xAFFEDEAD;
00189    // std::cout << "System::getProcedureByName>" << getLastErrorString() << std::endl;
00190     return 0;
00191   }
00192   return 1;
00193 #elif defined(__APPLE__)
00194   *pFunction = (EntryPoint)::dlsym(handle, name.c_str());
00195   if(!(*pFunction)) {
00196     // Try with an underscore :
00197     std::string sname = "_" + name; 
00198     *pFunction = (EntryPoint)::dlsym(handle, sname.c_str());
00199   }
00200   if ( 0 == *pFunction )    {
00201     errno = 0xAFFEDEAD;
00202     std::cout << "System::getProcedureByName>" << getLastErrorString() << std::endl;
00203     //std::cout << "System::getProcedureByName> failure" << std::endl;
00204     return 0;
00205   }
00206   return 1;
00207 #elif __hpux
00208   HMODULE* mod = (HMODULE*)handle;
00209   if ( 0 != mod ) {
00210     long ll1 = name.length();
00211     for ( int i = 0; i < mod->numSym; i++ ) {
00212       long ll2 = strlen(mod->sym[i].name);
00213       if ( 0 != ::strncmp(mod->sym[i].name, name.c_str(), (ll1>ll2) ? ll1 : ll2)==0 ) {
00214               *pFunction = (EntryPoint) mod->sym[i].value;
00215               return 1;
00216       }
00217     }
00218   }
00219   return 0;
00220 #endif
00221 }

unsigned long System::getProcedureByName ( ImageHandle  handle,
const std::string name,
Creator *  pFunction 
)

Get a specific function defined in the DLL.

Definition at line 224 of file System.cpp.

References getProcedureByName(), and name.

00224                                                                                                          {
00225   return getProcedureByName(handle, name, (EntryPoint*)pFunction);
00226 }

unsigned long System::getProcedureByName ( ImageHandle  handle,
const std::string name,
EntryPoint *  pFunction 
)

Get a specific function defined in the DLL.

Definition at line 178 of file System.cpp.

Referenced by getProcedureByName(), and unloadDynamicLib().

00178                                                                                                             {
00179 #ifdef _WIN32
00180   *pFunction = (EntryPoint)::GetProcAddress((HINSTANCE)handle, name.data());
00181   if ( 0 == *pFunction )    {
00182     return System::getLastError();
00183   }
00184   return 1;
00185 #elif defined(linux)
00186   *pFunction = (EntryPoint)::dlsym(handle, name.c_str());
00187   if ( 0 == *pFunction )    {
00188     errno = 0xAFFEDEAD;
00189    // std::cout << "System::getProcedureByName>" << getLastErrorString() << std::endl;
00190     return 0;
00191   }
00192   return 1;
00193 #elif defined(__APPLE__)
00194   *pFunction = (EntryPoint)::dlsym(handle, name.c_str());
00195   if(!(*pFunction)) {
00196     // Try with an underscore :
00197     std::string sname = "_" + name; 
00198     *pFunction = (EntryPoint)::dlsym(handle, sname.c_str());
00199   }
00200   if ( 0 == *pFunction )    {
00201     errno = 0xAFFEDEAD;
00202     std::cout << "System::getProcedureByName>" << getLastErrorString() << std::endl;
00203     //std::cout << "System::getProcedureByName> failure" << std::endl;
00204     return 0;
00205   }
00206   return 1;
00207 #elif __hpux
00208   HMODULE* mod = (HMODULE*)handle;
00209   if ( 0 != mod ) {
00210     long ll1 = name.length();
00211     for ( int i = 0; i < mod->numSym; i++ ) {
00212       long ll2 = strlen(mod->sym[i].name);
00213       if ( 0 != ::strncmp(mod->sym[i].name, name.c_str(), (ll1>ll2) ? ll1 : ll2)==0 ) {
00214               *pFunction = (EntryPoint) mod->sym[i].value;
00215               return 1;
00216       }
00217     }
00218   }
00219   return 0;
00220 #endif
00221 }

ProcessDescriptor * System::getProcess (  ) 

Retrieve Process structure.

Definition at line 213 of file ProcessDescriptor.cpp.

Referenced by affinityMask(), basePriority(), cpuTime(), creationTime(), ellapsedTime(), exitStatus(), kernelTime(), mappedMemory(), mappedMemoryPeak(), maxMemoryLimit(), minMemoryLimit(), nonPagedMemory(), nonPagedMemoryLimit(), nonPagedMemoryPeak(), numPageFault(), pagedMemory(), pagedMemoryLimit(), pagedMemoryPeak(), pagefileUsage(), pagefileUsageLimit(), pagefileUsagePeak(), parentID(), priorityBoost(), remainingTime(), userTime(), virtualMemory(), virtualMemoryLimit(), and virtualMemoryPeak().

00213                                               {
00214   static ProcessDescriptor p;
00215 #ifdef _WIN32
00216   static bool first = true;
00217   if ( first )    {
00218     first = false;
00219     void* mh = ::LoadLibrary("NTDll.dll");
00220     if ( mh )  {
00221       NtApi::NtQueryInformationProcess = (NtApi::__NtQueryInformationProcess)
00222         ::GetProcAddress((HINSTANCE)mh, "NtQueryInformationProcess");
00223     }
00224   }
00225 #endif
00226   return &p;
00227 }

bool System::getStackLevel ( void *addresses   __attribute__((unused)),
void *&addr   __attribute__((unused)),
std::string &fnc   __attribute__((unused)),
std::string &lib   __attribute__((unused)) 
)

Definition at line 696 of file System.cpp.

References abi::__cxa_demangle().

00700 {
00701 
00702 #ifdef __linux
00703 
00704   Dl_info info;
00705 
00706   if ( dladdr( addresses, &info ) && info.dli_fname 
00707       && info.dli_fname[0] != '\0' ) {
00708     const char* symbol = info.dli_sname 
00709     && info.dli_sname[0] != '\0' ? info.dli_sname : 0;
00710 
00711     lib = info.dli_fname;       
00712     addr = info.dli_saddr;
00713     const char* dmg(0);
00714 
00715     if (symbol != 0) {
00716       int stat;
00717       dmg = abi::__cxa_demangle(symbol,0,0,&stat);
00718       fnc = (stat == 0) ? dmg : symbol;   
00719     } else {
00720       fnc = "local";
00721     }
00722     free((void*)dmg);
00723     return true ;
00724   } else {
00725     return false ;
00726   }
00727 
00728 #else // not implemented for windows and osx
00729   return false ;
00730 #endif
00731 
00732 }

bool System::getStackLevel ( void *  addresses,
void *&  addr,
std::string fnc,
std::string lib 
)

Referenced by IssueLogger::getTraceBack(), and StatusCode::~StatusCode().

std::string System::homeDirectory (  ) 

Definition at line 57 of file Environment.cpp.

Referenced by tempDirectory().

00057                                  {
00058    // Return the user's home directory.
00059   std::string home_dir = "./";
00060   const char *h = 0;
00061   if ( 0 == (h = ::getenv("home")))  {
00062     h = ::getenv("HOME");
00063   }
00064   if ( h ) {
00065     home_dir = h;
00066   }
00067   else {
00068     // for Windows NT HOME might be defined as either $(HOMESHARE)/$(HOMEPATH)
00069     //                                         or     $(HOMEDRIVE)/$(HOMEPATH)
00070     h = ::getenv("HOMESHARE");
00071     if ( 0 == h )  {
00072       h = ::getenv("HOMEDRIVE");
00073     }
00074     if (h) {
00075       home_dir = h;
00076       h = ::getenv("HOMEPATH");
00077       if( h )  {
00078         home_dir += h;
00079       }
00080     }
00081   }
00082   return home_dir;
00083 }

std::string System::homeDirectory (  ) 

Definition at line 57 of file Environment.cpp.

Referenced by tempDirectory().

00057                                  {
00058    // Return the user's home directory.
00059   std::string home_dir = "./";
00060   const char *h = 0;
00061   if ( 0 == (h = ::getenv("home")))  {
00062     h = ::getenv("HOME");
00063   }
00064   if ( h ) {
00065     home_dir = h;
00066   }
00067   else {
00068     // for Windows NT HOME might be defined as either $(HOMESHARE)/$(HOMEPATH)
00069     //                                         or     $(HOMEDRIVE)/$(HOMEPATH)
00070     h = ::getenv("HOMESHARE");
00071     if ( 0 == h )  {
00072       h = ::getenv("HOMEDRIVE");
00073     }
00074     if (h) {
00075       home_dir = h;
00076       h = ::getenv("HOMEPATH");
00077       if( h )  {
00078         home_dir += h;
00079       }
00080     }
00081   }
00082   return home_dir;
00083 }

const std::string& System::hostName (  ) 

Host name.

Definition at line 477 of file System.cpp.

Referenced by ApplicationMgr::configure(), and JobHistory::JobHistory().

00477                                   {
00478   static std::string host = "";
00479   if ( host == "" ) {
00480     char buffer[512];
00481     memset(buffer,0,sizeof(buffer));
00482 #ifdef _WIN32
00483     unsigned long len = sizeof(buffer);
00484     ::GetComputerName(buffer, &len);
00485 #else
00486     ::gethostname(buffer, sizeof(buffer));
00487 #endif
00488     host = buffer;
00489   }
00490   return host;
00491 }

const std::string& System::hostName (  ) 

Host name.

Definition at line 477 of file System.cpp.

Referenced by ApplicationMgr::configure(), and JobHistory::JobHistory().

00477                                   {
00478   static std::string host = "";
00479   if ( host == "" ) {
00480     char buffer[512];
00481     memset(buffer,0,sizeof(buffer));
00482 #ifdef _WIN32
00483     unsigned long len = sizeof(buffer);
00484     ::GetComputerName(buffer, &len);
00485 #else
00486     ::gethostname(buffer, sizeof(buffer));
00487 #endif
00488     host = buffer;
00489   }
00490   return host;
00491 }

longlong System::kernelTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

CPU kernel mode time of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 150 of file Timing.cpp.

References adjustTime(), getProcess(), System::KERNEL_USER_TIMES::KernelTime, and NoFetch.

Referenced by ChronoEntity::start(), and ChronoEntity::stop().

00150                                                                   {
00151   KERNEL_USER_TIMES info;
00152   longlong kerneltime = 0;
00153   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00154     kerneltime = adjustTime(typ, info.KernelTime );
00155   }
00156   return kerneltime;
00157 }

longlong System::kernelTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

CPU kernel mode time of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 150 of file Timing.cpp.

References adjustTime(), getProcess(), System::KERNEL_USER_TIMES::KernelTime, and NoFetch.

Referenced by ChronoEntity::start(), and ChronoEntity::stop().

00150                                                                   {
00151   KERNEL_USER_TIMES info;
00152   longlong kerneltime = 0;
00153   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00154     kerneltime = adjustTime(typ, info.KernelTime );
00155   }
00156   return kerneltime;
00157 }

const std::vector<std::string> System::linkedModules (  ) 

Vector of names of linked modules.

Definition at line 213 of file ModuleInfo.cpp.

References name, processHandle(), and s_linkedModules.

00213                                                     {
00214   if ( s_linkedModules.size() == 0 )    {
00215 #ifdef _WIN32
00216     char   name[255];  // Maximum file name length on NT 4.0
00217     DWORD  cbNeeded;
00218     HINSTANCE handle[1024];
00219     if ( _psApi.isValid() )    {
00220       if ( _psApi.EnumProcessModules(processHandle(),handle,sizeof(handle),&cbNeeded) )   {
00221         for (size_t i = 0; i < cbNeeded/sizeof(HANDLE); i++ )    {
00222           if ( 0 < _psApi.GetModuleFileNameExA( processHandle(), handle[i], name, sizeof(name)) )   {
00223             s_linkedModules.push_back(name);
00224           }
00225         }
00226       }
00227     }
00228 #elif defined(linux) || defined(__APPLE__)
00229     char ff[512], cmd[1024], fname[1024], buf1[64], buf2[64], buf3[64], buf4[64];
00230     ::sprintf(ff, "/proc/%d/maps", ::getpid());
00231     FILE* maps = ::fopen(ff, "r");
00232     while( ::fgets(cmd, sizeof(cmd), maps) ) {
00233       int len;
00234       sscanf(cmd, "%s %s %s %s %d %s", buf1, buf2, buf3, buf4, &len, fname);
00235       if ( len > 0 && strncmp(buf2,"r-xp",strlen("r-xp")) == 0 ) {
00236         s_linkedModules.push_back(fname);
00237       }
00238     }
00239     ::fclose(maps);
00240 #endif
00241   }
00242   return s_linkedModules;
00243 }

const std::vector<std::string> System::linkedModules (  ) 

Vector of names of linked modules.

Definition at line 213 of file ModuleInfo.cpp.

References name, processHandle(), and s_linkedModules.

00213                                                     {
00214   if ( s_linkedModules.size() == 0 )    {
00215 #ifdef _WIN32
00216     char   name[255];  // Maximum file name length on NT 4.0
00217     DWORD  cbNeeded;
00218     HINSTANCE handle[1024];
00219     if ( _psApi.isValid() )    {
00220       if ( _psApi.EnumProcessModules(processHandle(),handle,sizeof(handle),&cbNeeded) )   {
00221         for (size_t i = 0; i < cbNeeded/sizeof(HANDLE); i++ )    {
00222           if ( 0 < _psApi.GetModuleFileNameExA( processHandle(), handle[i], name, sizeof(name)) )   {
00223             s_linkedModules.push_back(name);
00224           }
00225         }
00226       }
00227     }
00228 #elif defined(linux) || defined(__APPLE__)
00229     char ff[512], cmd[1024], fname[1024], buf1[64], buf2[64], buf3[64], buf4[64];
00230     ::sprintf(ff, "/proc/%d/maps", ::getpid());
00231     FILE* maps = ::fopen(ff, "r");
00232     while( ::fgets(cmd, sizeof(cmd), maps) ) {
00233       int len;
00234       sscanf(cmd, "%s %s %s %s %d %s", buf1, buf2, buf3, buf4, &len, fname);
00235       if ( len > 0 && strncmp(buf2,"r-xp",strlen("r-xp")) == 0 ) {
00236         s_linkedModules.push_back(fname);
00237       }
00238     }
00239     ::fclose(maps);
00240 #endif
00241   }
00242   return s_linkedModules;
00243 }

unsigned long System::loadDynamicLib ( const std::string name,
ImageHandle *  handle 
)

Load dynamic link library.

Definition at line 121 of file System.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), dllName, std::basic_string< _CharT, _Traits, _Alloc >::length(), loadWithoutEnvironment(), name, and SHLIB_SUFFIX.

Referenced by Gaudi::createInstance(), configGenerator::genConfig(), PoolDbCacheSvc::loadDictionary(), GaudiPython::Helper::loadDynamicLib(), and DLLClassManager::loadModule().

00121                                                                                {
00122   unsigned long res;
00123   // if name is empty, just load it
00124   if (name.length() == 0) {
00125     res = loadWithoutEnvironment(name, handle);
00126   } else {
00127     // If the name is a logical name (environment variable), the try
00128     // to load the corresponding library from there.
00129     std::string env = name;
00130     if ( 0 != ::getenv(env.c_str()) )    {
00131       std::string imgName = ::getenv(env.c_str());
00132       res = loadWithoutEnvironment(imgName, handle);
00133     } else {
00134       // build the dll name
00135       std::string dllName = name;
00136 #if defined(linux) || defined(__APPLE__)
00137       dllName = "lib" + dllName;
00138 #endif
00139       dllName += SHLIB_SUFFIX;
00140       // try to locate the dll using the standard PATH
00141       res = loadWithoutEnvironment(dllName, handle);
00142     }
00143     if ( res != 1 ) {
00144 #if defined(linux) || defined(__APPLE__)
00145       errno = 0xAFFEDEAD;
00146 #endif
00147      // std::cout << "System::loadDynamicLib>" << getLastErrorString() << std::endl;
00148     }
00149   }
00150   return res;
00151 }

unsigned long System::loadDynamicLib ( const std::string name,
ImageHandle *  handle 
)

Load dynamic link library.

Definition at line 121 of file System.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), dllName, std::basic_string< _CharT, _Traits, _Alloc >::length(), loadWithoutEnvironment(), name, and SHLIB_SUFFIX.

Referenced by Gaudi::createInstance(), configGenerator::genConfig(), PoolDbCacheSvc::loadDictionary(), GaudiPython::Helper::loadDynamicLib(), and DLLClassManager::loadModule().

00121                                                                                {
00122   unsigned long res;
00123   // if name is empty, just load it
00124   if (name.length() == 0) {
00125     res = loadWithoutEnvironment(name, handle);
00126   } else {
00127     // If the name is a logical name (environment variable), the try
00128     // to load the corresponding library from there.
00129     std::string env = name;
00130     if ( 0 != ::getenv(env.c_str()) )    {
00131       std::string imgName = ::getenv(env.c_str());
00132       res = loadWithoutEnvironment(imgName, handle);
00133     } else {
00134       // build the dll name
00135       std::string dllName = name;
00136 #if defined(linux) || defined(__APPLE__)
00137       dllName = "lib" + dllName;
00138 #endif
00139       dllName += SHLIB_SUFFIX;
00140       // try to locate the dll using the standard PATH
00141       res = loadWithoutEnvironment(dllName, handle);
00142     }
00143     if ( res != 1 ) {
00144 #if defined(linux) || defined(__APPLE__)
00145       errno = 0xAFFEDEAD;
00146 #endif
00147      // std::cout << "System::loadDynamicLib>" << getLastErrorString() << std::endl;
00148     }
00149   }
00150   return res;
00151 }

const std::string& System::machineType (  ) 

Machine type.

Definition at line 532 of file System.cpp.

Referenced by JobHistory::JobHistory().

00532                                      {
00533   static std::string mach = "";
00534 #ifdef _WIN32
00535   SYSTEM_INFO ut;
00536   ::GetSystemInfo(&ut);
00537   char arch[64];
00538   sprintf(arch,"%d",ut.wProcessorArchitecture);
00539   mach =  arch;
00540 #else
00541   struct utsname ut;
00542   if (uname(&ut) == 0) {
00543     mach = ut.machine;
00544   } else {
00545     mach = "UNKNOWN";
00546   }
00547 #endif
00548   return mach;
00549 }

const std::string& System::machineType (  ) 

Machine type.

Definition at line 532 of file System.cpp.

Referenced by JobHistory::JobHistory().

00532                                      {
00533   static std::string mach = "";
00534 #ifdef _WIN32
00535   SYSTEM_INFO ut;
00536   ::GetSystemInfo(&ut);
00537   char arch[64];
00538   sprintf(arch,"%d",ut.wProcessorArchitecture);
00539   mach =  arch;
00540 #else
00541   struct utsname ut;
00542   if (uname(&ut) == 0) {
00543     mach = ut.machine;
00544   } else {
00545     mach = "UNKNOWN";
00546   }
00547 #endif
00548   return mach;
00549 }

long System::mappedMemory ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: priority boost.

Definition at line 181 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::WorkingSetSize.

00181                                                                      {
00182   VM_COUNTERS info;
00183   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00184     return adjustMemory(unit, info.WorkingSetSize);
00185   return -2;
00186 }

long System::mappedMemory ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: priority boost.

Definition at line 181 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::WorkingSetSize.

00181                                                                      {
00182   VM_COUNTERS info;
00183   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00184     return adjustMemory(unit, info.WorkingSetSize);
00185   return -2;
00186 }

long System::mappedMemoryPeak ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: priority boost.

Definition at line 189 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PeakWorkingSetSize.

00189                                                                          {
00190   VM_COUNTERS info;
00191   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00192     return adjustMemory(unit, info.PeakWorkingSetSize);
00193   return -2;
00194 }

long System::mappedMemoryPeak ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: priority boost.

Definition at line 189 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PeakWorkingSetSize.

00189                                                                          {
00190   VM_COUNTERS info;
00191   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00192     return adjustMemory(unit, info.PeakWorkingSetSize);
00193   return -2;
00194 }

long System::maxMemoryLimit ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

System Process Limits: Maximum amount of virtual memory this process is allowed to use.

Definition at line 205 of file Memory.cpp.

References adjustMemory(), getProcess(), System::QUOTA_LIMITS::MaximumWorkingSetSize, and NoFetch.

00205                                                                        {
00206   QUOTA_LIMITS quota;
00207   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00208     return adjustMemory(unit, quota.MaximumWorkingSetSize);
00209   return 0;
00210 }

long System::maxMemoryLimit ( MemoryUnit  unit = kByte,
InfoType  fetch = Quota,
long  pid = -1 
)

System Process Limits: Maximum amount of virtual memory this process is allowed to use.

Definition at line 205 of file Memory.cpp.

References adjustMemory(), getProcess(), System::QUOTA_LIMITS::MaximumWorkingSetSize, and NoFetch.

00205                                                                        {
00206   QUOTA_LIMITS quota;
00207   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00208     return adjustMemory(unit, quota.MaximumWorkingSetSize);
00209   return 0;
00210 }

long System::minMemoryLimit ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

System Process Limits: Minimum amount of virtual memory this process may use.

Definition at line 197 of file Memory.cpp.

References adjustMemory(), getProcess(), System::QUOTA_LIMITS::MinimumWorkingSetSize, and NoFetch.

00197                                                                        {
00198   QUOTA_LIMITS quota;
00199   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00200     return adjustMemory(unit, quota.MinimumWorkingSetSize);
00201   return 0;
00202 }

long System::minMemoryLimit ( MemoryUnit  unit = kByte,
InfoType  fetch = Quota,
long  pid = -1 
)

System Process Limits: Minimum amount of virtual memory this process may use.

Definition at line 197 of file Memory.cpp.

References adjustMemory(), getProcess(), System::QUOTA_LIMITS::MinimumWorkingSetSize, and NoFetch.

00197                                                                        {
00198   QUOTA_LIMITS quota;
00199   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00200     return adjustMemory(unit, quota.MinimumWorkingSetSize);
00201   return 0;
00202 }

System::ImageHandle System::moduleHandle (  ) 

Handle to currently executed module.

Definition at line 132 of file ModuleInfo.cpp.

References moduleHandle(), ModuleHandle, and processHandle().

Referenced by moduleHandle(), moduleName(), and moduleNameFull().

00132                                           {
00133   if ( 0 == ModuleHandle )    {
00134     if ( processHandle() )    {
00135 #ifdef _WIN32
00136       static HINSTANCE handle = 0;
00137       DWORD   cbNeeded;
00138       if ( 0 == handle && _psApi.isValid() )    {
00139         if ( _psApi.EnumProcessModules( processHandle(), &handle, sizeof(ModuleHandle), &cbNeeded) )   {
00140         }
00141       }
00142       return handle;
00143 #elif defined(linux) || defined(__APPLE__)
00144       static Dl_info info;
00145       if ( 0 != ::dladdr((void*)System::moduleHandle, &info) ) {
00146         return &info;
00147       }
00148 #elif __hpux
00149       return 0;  // Don't know how to solve this .....
00150 #endif
00151     }
00152   }
00153   return ModuleHandle;
00154 }

ImageHandle System::moduleHandle (  ) 

Handle to currently executed module.

Definition at line 132 of file ModuleInfo.cpp.

References ModuleHandle, moduleHandle(), and processHandle().

Referenced by moduleHandle(), moduleName(), and moduleNameFull().

00132                                           {
00133   if ( 0 == ModuleHandle )    {
00134     if ( processHandle() )    {
00135 #ifdef _WIN32
00136       static HINSTANCE handle = 0;
00137       DWORD   cbNeeded;
00138       if ( 0 == handle && _psApi.isValid() )    {
00139         if ( _psApi.EnumProcessModules( processHandle(), &handle, sizeof(ModuleHandle), &cbNeeded) )   {
00140         }
00141       }
00142       return handle;
00143 #elif defined(linux) || defined(__APPLE__)
00144       static Dl_info info;
00145       if ( 0 != ::dladdr((void*)System::moduleHandle, &info) ) {
00146         return &info;
00147       }
00148 #elif __hpux
00149       return 0;  // Don't know how to solve this .....
00150 #endif
00151     }
00152   }
00153   return ModuleHandle;
00154 }

const std::string& System::moduleName (  ) 

Get the name of the (executable/DLL) file without file-type.

Definition at line 51 of file ModuleInfo.cpp.

References moduleHandle(), moduleName(), processHandle(), and std::basic_string< _CharT, _Traits, _Alloc >::substr().

Referenced by moduleName(), configGenerator::setConfigurableModule(), and PoolDbCnvFactory< ConcreteConverter, i >::typeName().

00051                                       {
00052   static std::string module("");
00053   if ( module == "" )   {
00054     if ( processHandle() && moduleHandle() )    {
00055 #ifdef _WIN32
00056       char moduleName[256] = {"Unknown.module"};
00057       moduleName[0] = 0;
00058       if ( _psApi.isValid() )   {
00059         _psApi.GetModuleBaseNameA( processHandle(), (HINSTANCE)moduleHandle(), moduleName, sizeof(moduleName) );
00060       }
00061       std::string mod = moduleName;
00062 #elif defined(linux) || defined(__APPLE__)
00063       std::string mod = ::basename((char*)((Dl_info*)moduleHandle())->dli_fname);
00064 #elif __hpux
00065       std::string mod = ::basename(((HMODULE*)moduleHandle())->dsc.filename);
00066 #endif
00067       module = mod.substr(0, mod.rfind('.'));
00068     }
00069   }
00070   return module;
00071 } 

const std::string& System::moduleName (  ) 

Get the name of the (executable/DLL) file without file-type.

Definition at line 51 of file ModuleInfo.cpp.

References moduleHandle(), moduleName(), processHandle(), and std::basic_string< _CharT, _Traits, _Alloc >::substr().

Referenced by moduleName(), configGenerator::setConfigurableModule(), and PoolDbCnvFactory< ConcreteConverter, i >::typeName().

00051                                       {
00052   static std::string module("");
00053   if ( module == "" )   {
00054     if ( processHandle() && moduleHandle() )    {
00055 #ifdef _WIN32
00056       char moduleName[256] = {"Unknown.module"};
00057       moduleName[0] = 0;
00058       if ( _psApi.isValid() )   {
00059         _psApi.GetModuleBaseNameA( processHandle(), (HINSTANCE)moduleHandle(), moduleName, sizeof(moduleName) );
00060       }
00061       std::string mod = moduleName;
00062 #elif defined(linux) || defined(__APPLE__)
00063       std::string mod = ::basename((char*)((Dl_info*)moduleHandle())->dli_fname);
00064 #elif __hpux
00065       std::string mod = ::basename(((HMODULE*)moduleHandle())->dsc.filename);
00066 #endif
00067       module = mod.substr(0, mod.rfind('.'));
00068     }
00069   }
00070   return module;
00071 } 

const std::string& System::moduleNameFull (  ) 

Get the full name of the (executable/DLL) file.

Definition at line 74 of file ModuleInfo.cpp.

References moduleHandle(), name, and processHandle().

Referenced by DLLClassManager::loadModule(), and moduleType().

00074                                           {
00075   static std::string module("");
00076   if ( module == "" )   {
00077     if ( processHandle() && moduleHandle() )    {
00078       char name[512] = {"Unknown.module"};
00079       name[0] = 0;
00080 #ifdef _WIN32
00081       if ( _psApi.isValid() )   {
00082         _psApi.GetModuleFileNameExA( processHandle(), (HINSTANCE)moduleHandle(), name,sizeof(name) );
00083       }
00084 #elif defined(linux) || defined(__APPLE__)
00085       ::realpath(((Dl_info*)moduleHandle())->dli_fname, name);
00086 #elif __hpux
00087       ::realpath(((HMODULE*)moduleHandle())->dsc.filename, name);
00088 #endif
00089       module = name;
00090     }
00091   }
00092   return module;
00093 }

const std::string& System::moduleNameFull (  ) 

Get the full name of the (executable/DLL) file.

Definition at line 74 of file ModuleInfo.cpp.

References moduleHandle(), name, and processHandle().

Referenced by DLLClassManager::loadModule(), and moduleType().

00074                                           {
00075   static std::string module("");
00076   if ( module == "" )   {
00077     if ( processHandle() && moduleHandle() )    {
00078       char name[512] = {"Unknown.module"};
00079       name[0] = 0;
00080 #ifdef _WIN32
00081       if ( _psApi.isValid() )   {
00082         _psApi.GetModuleFileNameExA( processHandle(), (HINSTANCE)moduleHandle(), name,sizeof(name) );
00083       }
00084 #elif defined(linux) || defined(__APPLE__)
00085       ::realpath(((Dl_info*)moduleHandle())->dli_fname, name);
00086 #elif __hpux
00087       ::realpath(((HMODULE*)moduleHandle())->dsc.filename, name);
00088 #endif
00089       module = name;
00090     }
00091   }
00092   return module;
00093 }

const System::ModuleType System::moduleType (  ) 

Get type of the module.

Definition at line 96 of file ModuleInfo.cpp.

References EXECUTABLE, moduleNameFull(), std::basic_string< _CharT, _Traits, _Alloc >::rfind(), SHAREDLIB, and UNKNOWN.

Referenced by PoolDbCnvFactory< ConcreteConverter, i >::typeName().

00096                                             {
00097   static ModuleType type = UNKNOWN;
00098   if ( type == UNKNOWN )    {
00099     const std::string& module = moduleNameFull();
00100     int loc = module.rfind('.')+1;
00101     if ( loc == 0 )
00102       type = EXECUTABLE;
00103     else if ( module[loc] == 'e' || module[loc] == 'E' )
00104       type = EXECUTABLE;
00105 #ifdef _WIN32
00106     else if ( module[loc] == 'd' || module[loc] == 'D' )
00107 #else
00108     else if ( module[loc] == 's' && module[loc+1] == 'o' )
00109 #endif
00110       type = SHAREDLIB;
00111     else
00112       type = UNKNOWN;
00113   }
00114   return type;
00115 }

const ModuleType System::moduleType (  ) 

Get type of the module.

Definition at line 96 of file ModuleInfo.cpp.

References EXECUTABLE, moduleNameFull(), std::basic_string< _CharT, _Traits, _Alloc >::rfind(), SHAREDLIB, and UNKNOWN.

Referenced by PoolDbCnvFactory< ConcreteConverter, i >::typeName().

00096                                             {
00097   static ModuleType type = UNKNOWN;
00098   if ( type == UNKNOWN )    {
00099     const std::string& module = moduleNameFull();
00100     int loc = module.rfind('.')+1;
00101     if ( loc == 0 )
00102       type = EXECUTABLE;
00103     else if ( module[loc] == 'e' || module[loc] == 'E' )
00104       type = EXECUTABLE;
00105 #ifdef _WIN32
00106     else if ( module[loc] == 'd' || module[loc] == 'D' )
00107 #else
00108     else if ( module[loc] == 's' && module[loc+1] == 'o' )
00109 #endif
00110       type = SHAREDLIB;
00111     else
00112       type = UNKNOWN;
00113   }
00114   return type;
00115 }

long System::nonPagedMemory ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Current usage of non paged memory.

Definition at line 106 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaNonPagedPoolUsage.

00106                                                                        {
00107   VM_COUNTERS info;
00108   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00109     return adjustMemory(unit, info.QuotaNonPagedPoolUsage);
00110   return -2;
00111 }

long System::nonPagedMemory ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: Current usage of non paged memory.

Definition at line 106 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaNonPagedPoolUsage.

00106                                                                        {
00107   VM_COUNTERS info;
00108   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00109     return adjustMemory(unit, info.QuotaNonPagedPoolUsage);
00110   return -2;
00111 }

long System::nonPagedMemoryLimit ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

System Process Limits: Maximum amount of non-paged memory this process is allowed to use.

Definition at line 114 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::POOLED_USAGE_AND_LIMITS::NonPagedPoolLimit.

00114                                                                             {
00115   POOLED_USAGE_AND_LIMITS quota;
00116   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00117     return adjustMemory(unit, quota.NonPagedPoolLimit);
00118   return 0;
00119 }

long System::nonPagedMemoryLimit ( MemoryUnit  unit = kByte,
InfoType  fetch = Quota,
long  pid = -1 
)

System Process Limits: Maximum amount of non-paged memory this process is allowed to use.

Definition at line 114 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::POOLED_USAGE_AND_LIMITS::NonPagedPoolLimit.

00114                                                                             {
00115   POOLED_USAGE_AND_LIMITS quota;
00116   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00117     return adjustMemory(unit, quota.NonPagedPoolLimit);
00118   return 0;
00119 }

long System::nonPagedMemoryPeak ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Peak usage of non paged memory.

Definition at line 98 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaPeakNonPagedPoolUsage.

00098                                                                            {
00099   VM_COUNTERS info;
00100   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00101     return adjustMemory(unit, info.QuotaPeakNonPagedPoolUsage);
00102   return -2;
00103 }

long System::nonPagedMemoryPeak ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: Peak usage of non paged memory.

Definition at line 98 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaPeakNonPagedPoolUsage.

00098                                                                            {
00099   VM_COUNTERS info;
00100   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00101     return adjustMemory(unit, info.QuotaPeakNonPagedPoolUsage);
00102   return -2;
00103 }

long System::numCmdLineArgs (  ) 

Number of arguments passed to the commandline.

Definition at line 571 of file System.cpp.

References cmdLineArgs().

00571                               {
00572   return cmdLineArgs().size();
00573 }

long System::numCmdLineArgs (  ) 

Number of arguments passed to the commandline.

Definition at line 571 of file System.cpp.

References cmdLineArgs().

00571                               {
00572   return cmdLineArgs().size();
00573 }

long System::numPageFault ( InfoType  fetch,
long  pid 
)

Basic Process Information: Number of page faults.

Definition at line 146 of file Memory.cpp.

References getProcess(), NoFetch, and System::VM_COUNTERS::PageFaultCount.

00146                                                     {
00147   VM_COUNTERS info;
00148   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00149     return info.PageFaultCount;
00150   return -2;
00151 }

long System::numPageFault ( InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: Number of page faults.

Definition at line 146 of file Memory.cpp.

References getProcess(), NoFetch, and System::VM_COUNTERS::PageFaultCount.

00146                                                     {
00147   VM_COUNTERS info;
00148   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00149     return info.PageFaultCount;
00150   return -2;
00151 }

const std::string& System::osName (  ) 

OS name.

Definition at line 494 of file System.cpp.

Referenced by JobHistory::JobHistory().

00494                                 {
00495   static std::string osname = "";
00496 #ifdef _WIN32
00497   osname = "Windows";
00498 #else
00499   struct utsname ut;
00500   if (uname(&ut) == 0) {
00501     osname = ut.sysname;
00502   } else {
00503     osname = "UNKNOWN";
00504   }
00505 #endif
00506   return osname;
00507 }

const std::string& System::osName (  ) 

OS name.

Definition at line 494 of file System.cpp.

Referenced by JobHistory::JobHistory().

00494                                 {
00495   static std::string osname = "";
00496 #ifdef _WIN32
00497   osname = "Windows";
00498 #else
00499   struct utsname ut;
00500   if (uname(&ut) == 0) {
00501     osname = ut.sysname;
00502   } else {
00503     osname = "UNKNOWN";
00504   }
00505 #endif
00506   return osname;
00507 }

const std::string& System::osVersion (  ) 

OS version.

Definition at line 511 of file System.cpp.

Referenced by JobHistory::JobHistory().

00511                                    {
00512   static std::string osver = "";
00513 #ifdef _WIN32
00514   OSVERSIONINFO ut;
00515   ut.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00516   ::GetVersionEx(&ut);
00517   char ver[64];
00518   sprintf(ver,"%d.%d",ut.dwMajorVersion,ut.dwMinorVersion);
00519   osver = ver;
00520 #else
00521   struct utsname ut;
00522   if (uname(&ut) == 0) {
00523     osver = ut.release;
00524   } else {
00525     osver = "UNKNOWN";
00526   }
00527 #endif
00528   return osver;
00529 }

const std::string& System::osVersion (  ) 

OS version.

Definition at line 511 of file System.cpp.

Referenced by JobHistory::JobHistory().

00511                                    {
00512   static std::string osver = "";
00513 #ifdef _WIN32
00514   OSVERSIONINFO ut;
00515   ut.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
00516   ::GetVersionEx(&ut);
00517   char ver[64];
00518   sprintf(ver,"%d.%d",ut.dwMajorVersion,ut.dwMinorVersion);
00519   osver = ver;
00520 #else
00521   struct utsname ut;
00522   if (uname(&ut) == 0) {
00523     osver = ut.release;
00524   } else {
00525     osver = "UNKNOWN";
00526   }
00527 #endif
00528   return osver;
00529 }

long System::pagedMemory ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Amount of paged memory currently occupied by the process 'pid'.

Definition at line 122 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaPagedPoolUsage.

00122                                                                     {
00123   VM_COUNTERS info;
00124   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00125     return adjustMemory(unit, info.QuotaPagedPoolUsage);
00126   return -2;
00127 }

long System::pagedMemory ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: Amount of paged memory currently occupied by the process 'pid'.

Definition at line 122 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaPagedPoolUsage.

00122                                                                     {
00123   VM_COUNTERS info;
00124   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00125     return adjustMemory(unit, info.QuotaPagedPoolUsage);
00126   return -2;
00127 }

long System::pagedMemoryLimit ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Amount of paged memory that can be occupied by the process 'pid'.

Definition at line 138 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::POOLED_USAGE_AND_LIMITS::PagedPoolLimit.

00138                                                                          {
00139   POOLED_USAGE_AND_LIMITS quota;
00140   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00141     return adjustMemory(unit, quota.PagedPoolLimit);
00142   return 0;
00143 }

long System::pagedMemoryLimit ( MemoryUnit  unit = kByte,
InfoType  fetch = Quota,
long  pid = -1 
)

Basic Process Information: Amount of paged memory that can be occupied by the process 'pid'.

Definition at line 138 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::POOLED_USAGE_AND_LIMITS::PagedPoolLimit.

00138                                                                          {
00139   POOLED_USAGE_AND_LIMITS quota;
00140   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )
00141     return adjustMemory(unit, quota.PagedPoolLimit);
00142   return 0;
00143 }

long System::pagedMemoryPeak ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Maximum of paged memory occupied by the process 'pid'.

Definition at line 130 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaPeakPagedPoolUsage.

00130                                                                         {
00131   VM_COUNTERS info;
00132   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00133     return adjustMemory(unit, info.QuotaPeakPagedPoolUsage);
00134   return -2;
00135 }

long System::pagedMemoryPeak ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: Maximum of paged memory occupied by the process 'pid'.

Definition at line 130 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::QuotaPeakPagedPoolUsage.

00130                                                                         {
00131   VM_COUNTERS info;
00132   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00133     return adjustMemory(unit, info.QuotaPeakPagedPoolUsage);
00134   return -2;
00135 }

long System::pagefileUsage ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Current page file usage.

Definition at line 154 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PagefileUsage.

00154                                                                       {
00155   VM_COUNTERS info;
00156   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00157     return adjustMemory(unit, info.PagefileUsage);
00158   return -2;
00159 }

long System::pagefileUsage ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: Current page file usage.

Definition at line 154 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PagefileUsage.

00154                                                                       {
00155   VM_COUNTERS info;
00156   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00157     return adjustMemory(unit, info.PagefileUsage);
00158   return -2;
00159 }

long System::pagefileUsageLimit ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Peak usage of page file.

Definition at line 170 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::POOLED_USAGE_AND_LIMITS::PagefileLimit.

00170                                                                            {
00171   POOLED_USAGE_AND_LIMITS quota;
00172   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )    {
00173     if ( long(quota.PagefileLimit) < 0 )
00174       return -1;//LONG_MAX;
00175     return adjustMemory(unit, quota.PagefileLimit);
00176   }
00177   return -2;
00178 }

long System::pagefileUsageLimit ( MemoryUnit  unit = kByte,
InfoType  fetch = Quota,
long  pid = -1 
)

Basic Process Information: Peak usage of page file.

Definition at line 170 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::POOLED_USAGE_AND_LIMITS::PagefileLimit.

00170                                                                            {
00171   POOLED_USAGE_AND_LIMITS quota;
00172   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )    {
00173     if ( long(quota.PagefileLimit) < 0 )
00174       return -1;//LONG_MAX;
00175     return adjustMemory(unit, quota.PagefileLimit);
00176   }
00177   return -2;
00178 }

long System::pagefileUsagePeak ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: Peak usage of page file.

Definition at line 162 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PeakPagefileUsage.

00162                                                                           {
00163   VM_COUNTERS info;
00164   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00165     return adjustMemory(unit, info.PeakPagefileUsage);
00166   return -2;
00167 }

long System::pagefileUsagePeak ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: Peak usage of page file.

Definition at line 162 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PeakPagefileUsage.

00162                                                                           {
00163   VM_COUNTERS info;
00164   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00165     return adjustMemory(unit, info.PeakPagefileUsage);
00166   return -2;
00167 }

long System::parentID ( InfoType  fetch,
long  pid 
)

Basic Process Information: Parent's process ID.

Definition at line 66 of file Memory.cpp.

References getProcess(), System::PROCESS_BASIC_INFORMATION::InheritedFromUniqueProcessId, NoFetch, and ProcessBasics.

00066                                                 {
00067   PROCESS_BASIC_INFORMATION info;
00068   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00069     return info.InheritedFromUniqueProcessId;
00070   return 0;
00071 }

long System::parentID ( InfoType  fetch = ProcessBasics,
long  pid = -1 
)

Basic Process Information: Parent's process ID.

Definition at line 66 of file Memory.cpp.

References getProcess(), System::PROCESS_BASIC_INFORMATION::InheritedFromUniqueProcessId, NoFetch, and ProcessBasics.

00066                                                 {
00067   PROCESS_BASIC_INFORMATION info;
00068   if ( fetch != NoFetch && getProcess()->query(pid, ProcessBasics, &info) )
00069     return info.InheritedFromUniqueProcessId;
00070   return 0;
00071 }

PathResolver::SearchPathStatus System::PathResolverCheckSearchPath ( const std::string search_path  ) 

Definition at line 598 of file PathResolver.cpp.

References System::PathResolver::check_search_path().

00599 {
00600   return PathResolver::check_search_path (search_path);
00601 }

std::string System::PathResolverFindDataFile ( const std::string logical_file_name  ) 

Definition at line 632 of file PathResolver.cpp.

References System::PathResolver::find_file().

00633 {
00634   return PathResolver::find_file (logical_file_name, "DATAPATH");
00635 }

std::string System::PathResolverFindDirectory ( const std::string logical_file_name,
const std::string search_path 
)

Definition at line 603 of file PathResolver.cpp.

References System::PathResolver::find_directory().

00605 {
00606   return PathResolver::find_directory (logical_file_name, search_path);
00607 }

std::string System::PathResolverFindDirectoryFromList ( const std::string logical_file_name,
const std::string search_list 
)

Definition at line 609 of file PathResolver.cpp.

References System::PathResolver::find_directory_from_list().

00611 {
00612   return PathResolver::find_directory_from_list (logical_file_name, search_list);
00613 }

std::string System::PathResolverFindFile ( const std::string logical_file_name,
const std::string search_path 
)

Definition at line 615 of file PathResolver.cpp.

References System::PathResolver::find_file().

00617 {
00618   return PathResolver::find_file (logical_file_name, search_path);
00619 }

std::string System::PathResolverFindFileFromList ( const std::string logical_file_name,
const std::string search_list 
)

Definition at line 621 of file PathResolver.cpp.

References System::PathResolver::find_file_from_list().

00623 {
00624   return PathResolver::find_file_from_list (logical_file_name, search_list);
00625 }

std::string System::PathResolverFindXMLFile ( const std::string logical_file_name  ) 

Definition at line 627 of file PathResolver.cpp.

References System::PathResolver::find_file().

00628 {
00629   return PathResolver::find_file (logical_file_name, "XMLPATH");
00630 }

static bool System::PR_absolute_path ( const std::string name  )  [static]

Definition at line 115 of file PathResolver.cpp.

References name, and std::basic_string< _CharT, _Traits, _Alloc >::size().

Referenced by PR_test_exist().

00116 {
00117   if (name.size () == 0) return (false);
00118 
00119   if ((name[0] == '/') ||
00120       (name[0] == '\\')) return (true);
00121 
00122   if (name.size () >= 2)
00123     {
00124       if (name[1] == ':')
00125         {
00126           return (true);
00127         }
00128     }
00129   return (false);
00130 }

static void System::PR_basename ( const std::string file_name,
std::string result 
) [static]

Definition at line 132 of file PathResolver.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::find_last_of(), std::basic_string< _CharT, _Traits, _Alloc >::npos, and std::basic_string< _CharT, _Traits, _Alloc >::substr().

Referenced by PR_find_from_list(), and PR_scan_dir().

00133 {
00134   std::string::size_type pos = file_name.find_last_of ('/');
00135 
00136   if (pos == std::string::npos)
00137     {
00138       pos = file_name.find_last_of ('\\');
00139     }
00140 
00141   if (pos == std::string::npos)
00142     {
00143       result = file_name;
00144     }
00145   else
00146     {
00147       result = file_name.substr (pos + 1);
00148     }
00149 }

static void System::PR_compress_path ( std::string dir  )  [static]

Definition at line 33 of file PathResolver.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::erase(), std::basic_string< _CharT, _Traits, _Alloc >::find(), std::basic_string< _CharT, _Traits, _Alloc >::find_last_of(), std::basic_string< _CharT, _Traits, _Alloc >::npos, std::basic_string< _CharT, _Traits, _Alloc >::size(), and std::basic_string< _CharT, _Traits, _Alloc >::substr().

Referenced by PR_test_exist().

00034 {
00035 #ifdef _WIN32
00036   static const char pattern[] = "\\..\\";
00037 #else
00038   static const char pattern[] = "/../";
00039 #endif
00040 
00041 #ifdef _WIN32
00042   static const char file_separator = '\\';
00043   static const char double_file_separator[] = "\\\\";
00044 #else
00045   static const char file_separator = '/';
00046   static const char double_file_separator[] = "//";
00047 #endif
00048 
00049   if (dir.size () == 0) return;
00050 
00051     //
00052     // We first synchronize to using file_separator() in any case.
00053     //
00054 
00055   for (;;)
00056     {
00057       std::string::size_type pos;
00058       pos = dir.find (double_file_separator);
00059       if (pos == std::string::npos) break;
00060       dir.erase (pos, 1);
00061     }
00062 
00063   for (;;)
00064     {
00065       std::string::size_type pos1;
00066       std::string::size_type pos2;
00067 
00068       pos1 = dir.find (pattern);
00069       if (pos1 == std::string::npos) break;
00070 
00071         //
00072         // extract "aaaa/xxxx" from "aaaa/xxxx/../bbbb"
00073         //
00074       std::string p = dir.substr (0, pos1);
00075       
00076         //
00077         // Is "aaaa/xxxx" only made of "xxxx" ?
00078         // 
00079       pos2 = p.find_last_of (file_separator);
00080       
00081       if (pos2 == std::string::npos) break;
00082       
00083         //    01234567890123456
00084         //    aaaa/xxxx/../bbbb
00085         //        2    1   3
00086         //
00087         // erase the "/xxxx/../" pattern
00088         // result will be "aaaa/bbbb"
00089         //
00090       dir.erase (pos2, pos1 + 4 - pos2 - 1);
00091     }
00092 
00093     //if (dir[dir.size () - 1] == file_separator ()) dir.erase (dir.size () - 1);
00094 }

static void System::PR_dirname ( const std::string file_name,
std::string result 
) [static]

Definition at line 96 of file PathResolver.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::erase(), std::basic_string< _CharT, _Traits, _Alloc >::find_last_of(), and std::basic_string< _CharT, _Traits, _Alloc >::npos.

Referenced by PR_find_from_list(), PR_scan_dir(), and PR_test_exist().

00097 {
00098   std::string::size_type pos = file_name.find_last_of ('/');
00099   if (pos == std::string::npos)
00100     {
00101       pos = file_name.find_last_of ('\\');
00102     }
00103 
00104   if (pos == std::string::npos)
00105     {
00106       result = "";
00107     }
00108   else
00109     {
00110       result = file_name;
00111       result.erase (pos);
00112     }
00113 }

static bool System::PR_find ( const std::string search_base,
const std::string logical_file_prefix,
const std::string logical_file_name,
PR_file_type  file_type,
PathResolver::SearchType  search_type,
std::string result 
) [static]

Definition at line 320 of file PathResolver.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), PR_directory, PR_scan_dir(), PR_test_exist(), and Gaudi::Units::s.

Referenced by PR_find_from_list().

00326 {
00327   static int level = 0;
00328 
00329 #ifdef _WIN32
00330   static const char file_separator = '\\';
00331 #else
00332   static const char file_separator = '/';
00333 #endif
00334 
00335   std::string file_path = "";
00336   std::string real_name = "";
00337 
00338   bool found = false;
00339 
00340   //PR_indent (level); std::cout << "PR_find> sb=" << search_base << " lfp=" << logical_file_prefix << " lfn=" << logical_file_name << std::endl;
00341 
00342   if (search_base != "")
00343     {
00344       file_path = search_base;
00345       file_path += file_separator;
00346     }
00347   else
00348     {
00349       file_path = "";
00350     }
00351 
00352   file_path += logical_file_name;
00353 
00354   //PR_indent (level); std::cout << "PR_find> test1 file_path=" << file_path << std::endl;
00355 
00356   result = file_path;
00357   if (PR_test_exist (file_path, result, file_type))
00358     {
00359       found = true;
00360     }
00361 
00362   if (!found && (logical_file_prefix != ""))
00363     {
00364       if (search_base != "")
00365         {
00366           file_path = search_base;
00367           file_path += file_separator;
00368         }
00369       else
00370         {
00371           file_path = "";
00372         }
00373 
00374       file_path += logical_file_prefix;
00375       file_path += file_separator;
00376       file_path += logical_file_name;
00377 
00378       //PR_indent (level); std::cout << "PR_find> test2 file_path=" << file_path << std::endl;
00379 
00380       result = file_path;
00381       if (PR_test_exist (file_path, result, file_type))
00382         {
00383           found = true;
00384         }
00385     }
00386 
00387   //PR_indent (level); std::cout << "PR_find> test3 found=" << found << " search_type=" << search_type << std::endl;
00388 
00389   if (!found && (search_type == PathResolver::RecursiveSearch))
00390     {
00391       std::string dir_name = "";
00392       std::string file_name = "";
00393       std::vector<std::string> list;
00394 
00395       PR_scan_dir (search_base, list);
00396 
00397       std::vector<std::string>::iterator it;
00398 
00399       for (it = list.begin (); it != list.end (); ++it)
00400         {
00401           const std::string& d = *it;
00402 
00403           if (PR_test_exist (d, file_path, PR_directory))
00404             {
00405               //PR_indent (level); std::cout << "d=" << d << std::endl;
00406 
00407               level++;
00408               bool s = PR_find (d, logical_file_prefix, logical_file_name, file_type, search_type, result);
00409               level--;
00410 
00411               if (s)
00412                 {
00413                   //PR_indent (level); std::cout << "PR_find> result=" << result << std::endl;
00414                   found = true;
00415                   break;
00416                 }
00417             }
00418         }
00419     }
00420 
00421   return (found);
00422 }

static bool System::PR_find_from_list ( const std::string logical_file_name,
const std::string search_list,
PR_file_type  file_type,
PathResolver::SearchType  search_type,
std::string result 
) [static]

Definition at line 424 of file PathResolver.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::find(), std::basic_string< _CharT, _Traits, _Alloc >::npos, Gaudi::Utils::Histos::path(), PR_basename(), PR_dirname(), PR_find(), and std::basic_string< _CharT, _Traits, _Alloc >::substr().

Referenced by System::PathResolver::find_directory_from_list(), and System::PathResolver::find_file_from_list().

00429 {
00430 #ifdef _WIN32
00431   static const char path_separator = ';';
00432 #else
00433   static const char path_separator = ':';
00434 #endif
00435 
00436   std::string::size_type pos = 0;
00437 
00438   std::string file_name = "";
00439   std::string file_prefix = "";
00440 
00441   PR_basename (logical_file_name, file_name);
00442   PR_dirname (logical_file_name, file_prefix);
00443 
00444   std::string real_name = "";
00445 
00446   bool found = false;
00447 
00448   if (PR_find ("", file_prefix, file_name, file_type, search_type, result))
00449     {
00450       found = true;
00451     }
00452 
00453   if (!found)
00454     {
00455       for (int i = 0;;i++)
00456         {
00457           bool ending = false;
00458 
00459           std::string::size_type next = search_list.find (path_separator, pos);
00460 
00461           std::string path = search_list.substr (pos, next - pos);
00462 
00463           if (next == std::string::npos)
00464             {
00465               path = search_list.substr (pos);
00466               ending = true;
00467             }
00468           else
00469             {
00470               path = search_list.substr (pos, next - pos);
00471               pos = next + 1;
00472             }
00473           
00474           //std::cout << "path[" << i << "]=" << path << std::endl;
00475           
00476           if (PR_find (path, file_prefix, file_name, file_type, search_type, result))
00477             {
00478               found = true;
00479               break;
00480             }
00481           
00482           if (ending) break;
00483         }
00484     }
00485 
00486   return (found);
00487 }

static void System::PR_scan_dir ( const std::string dir_name,
std::vector< std::string > &  list 
) [static]

Definition at line 212 of file PathResolver.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::vector< _Tp, _Alloc >::clear(), std::basic_string< _CharT, _Traits, _Alloc >::erase(), std::basic_string< _CharT, _Traits, _Alloc >::find(), name, std::basic_string< _CharT, _Traits, _Alloc >::npos, PR_basename(), PR_directory, PR_dirname(), PR_test_exist(), std::vector< _Tp, _Alloc >::push_back(), search(), and std::basic_string< _CharT, _Traits, _Alloc >::size().

Referenced by PR_find().

00214 {
00215 #ifdef _WIN32
00216   static const char file_separator = '\\';
00217 #else
00218   static const char file_separator = '/';
00219 #endif
00220 
00221   static std::string dir_prefix;
00222   static std::string name_prefix;
00223   static std::string real_name;
00224 
00225   dir_prefix = dir_name;
00226   if (dir_name == "") dir_prefix = ".";
00227 
00228   //std::cout << "PR_scan_dir1> dir_name=" << dir_name << " dir_prefix=" << dir_prefix << std::endl;
00229 
00230   if (!PR_test_exist (dir_prefix, real_name, PR_directory)) {
00231     PR_dirname (dir_prefix, dir_prefix);
00232     PR_basename (dir_name, name_prefix);
00233   }
00234 
00235   bool need_filter = false;
00236 
00237   std::string::size_type wild_card;
00238 
00239   wild_card = name_prefix.find ('*');
00240   if (wild_card != std::string::npos) {
00241     name_prefix.erase (wild_card);
00242 
00243     if (name_prefix.size () > 0) {
00244       need_filter = true;
00245     }
00246   }
00247 
00248   list.clear();
00249 
00250 #ifdef _WIN32
00251 
00252   long dir;
00253   struct _finddata_t entry;
00254 
00255   static std::string search;
00256 
00257   search = dir_prefix;
00258   search += file_separator;
00259   search += "*";
00260 
00261   dir = _findfirst (search.c_str (), &entry);
00262   if (dir > 0) {
00263     for (;;)   {
00264       if ((strcmp ((char*) entry.name, ".") != 0) &&
00265           (strcmp ((char*) entry.name, "..") != 0) &&
00266           (strncmp ((char*) entry.name, ".nfs", 4) != 0)) {
00267         const char* name = entry.name;
00268 
00269         if (need_filter && 
00270           (strncmp (name, name_prefix.c_str (), name_prefix.size ()) == 0)) continue;
00271         std::string name_entry;
00272         name_entry = dir_prefix;
00273         name_entry += file_separator;
00274         name_entry += name;
00275 
00276         list.push_back (name_entry);
00277       }
00278 
00279       int status = _findnext (dir, &entry);
00280       if (status != 0) {
00281         break;
00282       }
00283     }
00284     _findclose (dir);
00285   }
00286 #else
00287 
00288   DIR* dir = opendir (dir_prefix.c_str ());
00289 
00290   struct dirent* entry;
00291 
00292   if (dir != 0) {
00293     while ((entry = readdir (dir)) != 0) {
00294       //if (entry->d_name[0] == '.') continue;
00295       if (!strcmp ((char*) entry->d_name, ".")) continue;
00296       if (!strcmp ((char*) entry->d_name, "..")) continue;
00297       if (!strncmp ((char*) entry->d_name, ".nfs", 4)) continue;
00298 
00299       const char* name = entry->d_name;
00300 
00301       //std::cout << "scan_dir4> name=" << name << std::endl;
00302 
00303       if (need_filter &&
00304           (strncmp (name, name_prefix.c_str (), name_prefix.size ()) != 0)) continue;
00305 
00306       std::string name_entry;
00307 
00308       name_entry = dir_prefix;
00309       name_entry += file_separator;
00310       name_entry += name;
00311 
00312       list.push_back (name_entry);
00313     }
00314     closedir (dir);
00315   }
00316 #endif
00317 }

static bool System::PR_test_exist ( const std::string name,
std::string real_name,
PR_file_type  file_type 
) [static]

Definition at line 151 of file PathResolver.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), name, PR_absolute_path(), PR_compress_path(), and PR_dirname().

Referenced by System::PathResolver::check_search_path(), PR_find(), and PR_scan_dir().

00152 {
00153   struct stat file_stat;
00154   int status;
00155 
00156   char buf[1024];
00157   strcpy (buf, name.c_str ());
00158 
00159 #ifdef _WIN32
00160   static const char file_separator = '\\';
00161 #else
00162   static const char file_separator = '/';
00163 #endif
00164 
00165   real_name = name;
00166 #ifndef _WIN32
00167   for (;;) {
00168     status = lstat (buf, &file_stat);
00169     if (status == 0) {
00170           if (S_ISLNK (file_stat.st_mode) != 0) {
00171             //std::cout << "#1 " << buf << " stat=" << std::oct << file_stat.st_mode << std::dec << std::endl;
00172             int n = readlink (buf, buf, sizeof (buf));
00173             if (n >= 0) buf[n] = 0;
00174             //std::cout << "test_exist> buf=" << buf << std::endl;
00175             if (PR_absolute_path (buf)) { 
00176           real_name = buf;
00177         }
00178             else {
00179           PR_dirname (real_name, real_name);
00180           real_name += file_separator;
00181           real_name += buf;
00182           PR_compress_path (real_name);
00183           strcpy (buf, real_name.c_str ());
00184         }
00185             //std::cout << "#2 " << real_name << std::endl;
00186             //break;
00187       }
00188       else { 
00189         break;
00190       }
00191     }
00192     else {
00193       break;
00194     }
00195   }
00196 #endif
00197   status = stat (name.c_str (), &file_stat);
00198 
00199   if (status == 0) {
00200     if ((file_stat.st_mode & S_IFDIR) == 0) {
00201       return (file_type == PR_regular_file);
00202     }
00203     else {
00204       return (file_type == PR_directory);
00205     }
00206   }
00207   else {
00208     return (false);
00209   }
00210 }

long System::priorityBoost ( InfoType  fetch,
long  pid 
)

Basic Process Information: priority boost.

Definition at line 90 of file Memory.cpp.

References getProcess(), and NoFetch.

00090                                                      {
00091   long info;
00092   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00093     return info;
00094   return -2;
00095 }

long System::priorityBoost ( InfoType  fetch = PriorityBoost,
long  pid = -1 
)

Basic Process Information: priority boost.

Definition at line 90 of file Memory.cpp.

References getProcess(), and NoFetch.

00090                                                      {
00091   long info;
00092   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00093     return info;
00094   return -2;
00095 }

void* System::processHandle (  ) 

Handle to running process.

Definition at line 118 of file ModuleInfo.cpp.

Referenced by exeHandle(), exeName(), linkedModules(), moduleHandle(), moduleName(), moduleNameFull(), and System::ProcessDescriptor::ProcessHandle::ProcessHandle().

00118                               {
00119   static long pid = ::getpid();
00120 #ifdef _WIN32
00121   static HANDLE hP = ::OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,pid);
00122 #else
00123   static void* hP = (void*)pid;
00124 #endif
00125   return hP;
00126 }

ProcessHandle System::processHandle (  ) 

Handle to running process.

Definition at line 118 of file ModuleInfo.cpp.

Referenced by exeHandle(), exeName(), linkedModules(), moduleHandle(), moduleName(), moduleNameFull(), and System::ProcessDescriptor::ProcessHandle::ProcessHandle().

00118                               {
00119   static long pid = ::getpid();
00120 #ifdef _WIN32
00121   static HANDLE hP = ::OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,pid);
00122 #else
00123   static void* hP = (void*)pid;
00124 #endif
00125   return hP;
00126 }

long System::procID (  ) 

Basic Process Information: Process ID.

Definition at line 60 of file Memory.cpp.

00060                       {
00061   static long s_pid = ::getpid();
00062   return s_pid;
00063 }

long System::procID (  ) 

Basic Process Information: Process ID.

Definition at line 60 of file Memory.cpp.

00060                       {
00061   static long s_pid = ::getpid();
00062   return s_pid;
00063 }

longlong System::remainingTime ( TimeType  typ = milliSec,
InfoType  fetch = Quota,
long  pid = -1 
)

Maximum processing time left for this process.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 126 of file Timing.cpp.

References adjustTime(), getProcess(), left(), NoFetch, and System::QUOTA_LIMITS::TimeLimit.

00126                                                                        {
00127   longlong left = 0;
00128   QUOTA_LIMITS quota;
00129   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )   {
00130     if ( left == -1 )     {
00131       //left = _I64_MAX;
00132     }
00133     else  {
00134       left = adjustTime(typ, quota.TimeLimit);
00135     }
00136   }
00137   return left;
00138 }

longlong System::remainingTime ( TimeType  typ = milliSec,
InfoType  fetch = Quota,
long  pid = -1 
)

Maximum processing time left for this process.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 126 of file Timing.cpp.

References adjustTime(), getProcess(), left(), NoFetch, and System::QUOTA_LIMITS::TimeLimit.

00126                                                                        {
00127   longlong left = 0;
00128   QUOTA_LIMITS quota;
00129   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )   {
00130     if ( left == -1 )     {
00131       //left = _I64_MAX;
00132     }
00133     else  {
00134       left = adjustTime(typ, quota.TimeLimit);
00135     }
00136   }
00137   return left;
00138 }

StatusCode System::resolveEnv ( const std::string var,
std::string res,
int  recursions 
)

Definition at line 48 of file Environment.cpp.

References StatusCode::FAILURE, std::basic_string< _CharT, _Traits, _Alloc >::find(), i_resolve(), std::basic_string< _CharT, _Traits, _Alloc >::npos, and StatusCode::SUCCESS.

Referenced by Tokenizer::Token::resolveValue().

00048                                                                                    {
00049   std::string source = var;
00050   res = i_resolve(source, recursions);
00051   if ( res.find("${") == std::string::npos ) {
00052     return StatusCode::SUCCESS;
00053   }
00054   return StatusCode::FAILURE;
00055 }

StatusCode System::resolveEnv ( const std::string var,
std::string res,
int  recusions = 124 
)

Definition at line 48 of file Environment.cpp.

References StatusCode::FAILURE, std::basic_string< _CharT, _Traits, _Alloc >::find(), i_resolve(), std::basic_string< _CharT, _Traits, _Alloc >::npos, and StatusCode::SUCCESS.

Referenced by Tokenizer::Token::resolveValue().

00048                                                                                    {
00049   std::string source = var;
00050   res = i_resolve(source, recursions);
00051   if ( res.find("${") == std::string::npos ) {
00052     return StatusCode::SUCCESS;
00053   }
00054   return StatusCode::FAILURE;
00055 }

int System::setEnv ( const std::string name,
const std::string value,
int  overwrite 
)

Set an environment variables.

Returns:
0 if successful, -1 if not

Definition at line 735 of file System.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::basic_string< _CharT, _Traits, _Alloc >::empty(), and name.

Referenced by ApplicationMgr::configure().

00736 {
00737 #ifndef WIN32
00738   // UNIX version
00739   return value.empty() ?
00740     // remove if set to nothing (and return success)
00741     ::unsetenv(name.c_str()) , 0 :
00742     // set the value
00743     ::setenv(name.c_str(),value.c_str(), overwrite);
00744 #else
00745   // Windows version
00746   if ( value.empty() ) {
00747     // equivalent to unsetenv
00748     return ::_putenv((name+"=").c_str());
00749   }
00750   else {
00751     if ( !getenv(name.c_str()) || overwrite ) {
00752       // set if not yet present or overwrite is set (force)
00753       return ::_putenv((name+"="+value).c_str());
00754     }
00755   }
00756   return 0; // if we get here, we are trying to set a variable already set, but
00757             // not to overwrite.
00758             // It is considered a success on Linux (man P setenv)
00759 #endif
00760   
00761 }

int System::setEnv ( const std::string name,
const std::string value,
int  overwrite 
)

Set an environment variables.

Returns:
0 if successful, -1 if not

Definition at line 735 of file System.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), std::basic_string< _CharT, _Traits, _Alloc >::empty(), and name.

Referenced by ApplicationMgr::configure().

00736 {
00737 #ifndef WIN32
00738   // UNIX version
00739   return value.empty() ?
00740     // remove if set to nothing (and return success)
00741     ::unsetenv(name.c_str()) , 0 :
00742     // set the value
00743     ::setenv(name.c_str(),value.c_str(), overwrite);
00744 #else
00745   // Windows version
00746   if ( value.empty() ) {
00747     // equivalent to unsetenv
00748     return ::_putenv((name+"=").c_str());
00749   }
00750   else {
00751     if ( !getenv(name.c_str()) || overwrite ) {
00752       // set if not yet present or overwrite is set (force)
00753       return ::_putenv((name+"="+value).c_str());
00754     }
00755   }
00756   return 0; // if we get here, we are trying to set a variable already set, but
00757             // not to overwrite.
00758             // It is considered a success on Linux (man P setenv)
00759 #endif
00760   
00761 }

void System::setModuleHandle ( System::ImageHandle  handle  ) 

Attach module handle.

Definition at line 128 of file ModuleInfo.cpp.

References ModuleHandle.

00128                                                         {
00129   ModuleHandle = handle;
00130 }

void System::setModuleHandle ( ImageHandle  handle  ) 

Attach module handle.

Definition at line 128 of file ModuleInfo.cpp.

References ModuleHandle.

00128                                                         {
00129   ModuleHandle = handle;
00130 }

longlong System::systemStart ( TimeType  typ = Sec  ) 

Maximum processing time left for this process.

Parameters:
typ Indicator or the unit the time will be returned.
Returns:
Requested value in the indicated units.

Definition at line 99 of file Timing.cpp.

References adjustTime(), c, currentTime(), microSec, and tickCount().

Referenced by upTime().

00099                                             {
00100   static longlong sys_start = 0;
00101   if ( 0 == sys_start )   {
00102     longlong c = currentTime(microSec);
00103     longlong t = tickCount();
00104     sys_start = 10*c - t;
00105   }
00106   return adjustTime(typ, sys_start);
00107 }

longlong System::systemStart ( TimeType  typ = Sec  ) 

Maximum processing time left for this process.

Parameters:
typ Indicator or the unit the time will be returned.
Returns:
Requested value in the indicated units.

Definition at line 99 of file Timing.cpp.

References adjustTime(), c, currentTime(), microSec, and tickCount().

Referenced by upTime().

00099                                             {
00100   static longlong sys_start = 0;
00101   if ( 0 == sys_start )   {
00102     longlong c = currentTime(microSec);
00103     longlong t = tickCount();
00104     sys_start = 10*c - t;
00105   }
00106   return adjustTime(typ, sys_start);
00107 }

std::string System::tempDirectory (  ) 

Definition at line 85 of file Environment.cpp.

References homeDirectory().

00085                                   {
00086    // Return a user configured or systemwide directory to create
00087    // temporary files in.
00088    const char *dir = ::getenv("TEMP");
00089    if (!dir)   dir = ::getenv("TEMPDIR");
00090    if (!dir)   dir = ::getenv("TEMP_DIR");
00091    if (!dir)   dir = ::getenv("TMP");
00092    if (!dir)   dir = ::getenv("TMPDIR");
00093    if (!dir)   dir = ::getenv("TMP_DIR");
00094    if (!dir) return homeDirectory();
00095    return dir;
00096 }

std::string System::tempDirectory (  ) 

Definition at line 85 of file Environment.cpp.

References homeDirectory().

00085                                   {
00086    // Return a user configured or systemwide directory to create
00087    // temporary files in.
00088    const char *dir = ::getenv("TEMP");
00089    if (!dir)   dir = ::getenv("TEMPDIR");
00090    if (!dir)   dir = ::getenv("TEMP_DIR");
00091    if (!dir)   dir = ::getenv("TMP");
00092    if (!dir)   dir = ::getenv("TMPDIR");
00093    if (!dir)   dir = ::getenv("TMP_DIR");
00094    if (!dir) return homeDirectory();
00095    return dir;
00096 }

ThreadHandle System::threadSelf (  )  [inline]

thread handle "accessor"

Definition at line 93 of file System.h.

Referenced by ThreadGaudi::getThreadID(), and ThreadGaudi::setThreadID().

00093 { return (void*)0; }

longlong System::tickCount (  ) 

Retrieve the number of ticks since system startup.

Returns:
Requested value in the indicated units.

Definition at line 67 of file Timing.cpp.

References count().

Referenced by systemStart().

00067                               {
00068   longlong count = 10000;
00069 #ifdef _WIN32
00070   count *= ::GetTickCount(); // Number of milliSec since system startup
00071 #else
00072   struct tms buf;
00073   count *= 10*times(&buf);
00074 #endif
00075   return count;
00076 }

longlong System::tickCount (  ) 

Retrieve the number of ticks since system startup.

Returns:
Requested value in the indicated units.

Definition at line 67 of file Timing.cpp.

References count().

Referenced by systemStart().

00067                               {
00068   longlong count = 10000;
00069 #ifdef _WIN32
00070   count *= ::GetTickCount(); // Number of milliSec since system startup
00071 #else
00072   struct tms buf;
00073   count *= 10*times(&buf);
00074 #endif
00075   return count;
00076 }

const std::string System::typeinfoName ( const char *  class_name  ) 

Definition at line 355 of file System.cpp.

References abi::__cxa_demangle(), std::basic_string< _CharT, _Traits, _Alloc >::erase(), std::basic_string< _CharT, _Traits, _Alloc >::find(), std::basic_string< _CharT, _Traits, _Alloc >::npos, and std::basic_string< _CharT, _Traits, _Alloc >::replace().

00355                                                             {
00356   std::string result;
00357 #ifdef _WIN32
00358   long off = 0;
00359   if ( ::strncmp(class_name, "class ", 6) == 0 )   {
00360     // The returned name is prefixed with "class "
00361     off = 6;
00362   }
00363   if ( ::strncmp(class_name, "struct ", 7) == 0 )   {
00364     // The returned name is prefixed with "struct "
00365     off = 7;
00366   }
00367   if ( off > 0 )    {
00368     std::string tmp = class_name + off;
00369     long loc = 0;
00370     while( (loc = tmp.find("class ")) > 0 )  {
00371       tmp.erase(loc, 6);
00372     }
00373     loc = 0;
00374     while( (loc = tmp.find("struct ")) > 0 )  {
00375       tmp.erase(loc, 7);
00376     }
00377     result = tmp;
00378   }
00379   else  {
00380     result = class_name;
00381   }
00382   // Change any " *" to "*"
00383   while ( (off=result.find(" *")) != std::string::npos ) {
00384     result.replace(off, 2, "*");
00385   }
00386   // Change any " &" to "&"
00387   while ( (off=result.find(" &")) != std::string::npos ) {
00388     result.replace(off, 2, "&");
00389   }
00390 
00391 #elif defined(__linux) || defined(__APPLE__)
00392     if ( ::strlen(class_name) == 1 ) {
00393       // See http://www.realitydiluted.com/mirrors/reality.sgi.com/dehnert_engr/cxx/abi.pdf
00394       // for details
00395       switch(class_name[0]) {
00396       case 'v':
00397         result = "void";
00398         break;
00399       case 'w':
00400         result = "wchar_t";
00401         break;
00402       case 'b':
00403         result = "bool";
00404         break;
00405       case 'c':
00406         result = "char";
00407         break;
00408       case 'h':
00409         result = "unsigned char";
00410         break;
00411       case 's':
00412         result = "short";
00413         break;
00414       case 't':
00415         result = "unsigned short";
00416         break;
00417       case 'i':
00418         result = "int";
00419         break;
00420       case 'j':
00421         result = "unsigned int";
00422         break;
00423       case 'l':
00424         result = "long";
00425         break;
00426       case 'm':
00427         result = "unsigned long";
00428         break;
00429       case 'x':
00430         result = "long long";
00431         break;
00432       case 'y':
00433         result = "unsigned long long";
00434         break;
00435       case 'n':
00436         result = "__int128";
00437         break;
00438       case 'o':
00439         result = "unsigned __int128";
00440         break;
00441       case 'f':
00442         result = "float";
00443         break;
00444       case 'd':
00445         result = "double";
00446         break;
00447       case 'e':
00448         result = "long double";
00449         break;
00450       case 'g':
00451         result = "__float128";
00452         break;
00453       case 'z':
00454         result = "ellipsis";
00455         break;
00456       }
00457     }
00458     else  {
00459       int   status;
00460       char* realname;
00461       realname = abi::__cxa_demangle(class_name, 0, 0, &status);
00462       if (realname == 0) return class_name;
00463       result = realname;
00464       free(realname);
00466       std::string::size_type pos = result.find(", ");
00467       while( std::string::npos != pos ) {
00468         result.replace( pos , 2 , "," ) ;
00469         pos = result.find(", ");
00470       }
00471     }
00472 #endif
00473   return result;
00474 }

const std::string System::typeinfoName ( const std::type_info tinfo  ) 

Get platform independent information about the class type.

Definition at line 352 of file System.cpp.

References std::type_info::name(), and typeinfoName().

00352                                                                {
00353   return typeinfoName(tinfo.name());
00354 }

const std::string System::typeinfoName ( const char *   ) 

Definition at line 355 of file System.cpp.

References abi::__cxa_demangle(), std::basic_string< _CharT, _Traits, _Alloc >::erase(), std::basic_string< _CharT, _Traits, _Alloc >::find(), std::basic_string< _CharT, _Traits, _Alloc >::npos, and std::basic_string< _CharT, _Traits, _Alloc >::replace().

00355                                                             {
00356   std::string result;
00357 #ifdef _WIN32
00358   long off = 0;
00359   if ( ::strncmp(class_name, "class ", 6) == 0 )   {
00360     // The returned name is prefixed with "class "
00361     off = 6;
00362   }
00363   if ( ::strncmp(class_name, "struct ", 7) == 0 )   {
00364     // The returned name is prefixed with "struct "
00365     off = 7;
00366   }
00367   if ( off > 0 )    {
00368     std::string tmp = class_name + off;
00369     long loc = 0;
00370     while( (loc = tmp.find("class ")) > 0 )  {
00371       tmp.erase(loc, 6);
00372     }
00373     loc = 0;
00374     while( (loc = tmp.find("struct ")) > 0 )  {
00375       tmp.erase(loc, 7);
00376     }
00377     result = tmp;
00378   }
00379   else  {
00380     result = class_name;
00381   }
00382   // Change any " *" to "*"
00383   while ( (off=result.find(" *")) != std::string::npos ) {
00384     result.replace(off, 2, "*");
00385   }
00386   // Change any " &" to "&"
00387   while ( (off=result.find(" &")) != std::string::npos ) {
00388     result.replace(off, 2, "&");
00389   }
00390 
00391 #elif defined(__linux) || defined(__APPLE__)
00392     if ( ::strlen(class_name) == 1 ) {
00393       // See http://www.realitydiluted.com/mirrors/reality.sgi.com/dehnert_engr/cxx/abi.pdf
00394       // for details
00395       switch(class_name[0]) {
00396       case 'v':
00397         result = "void";
00398         break;
00399       case 'w':
00400         result = "wchar_t";
00401         break;
00402       case 'b':
00403         result = "bool";
00404         break;
00405       case 'c':
00406         result = "char";
00407         break;
00408       case 'h':
00409         result = "unsigned char";
00410         break;
00411       case 's':
00412         result = "short";
00413         break;
00414       case 't':
00415         result = "unsigned short";
00416         break;
00417       case 'i':
00418         result = "int";
00419         break;
00420       case 'j':
00421         result = "unsigned int";
00422         break;
00423       case 'l':
00424         result = "long";
00425         break;
00426       case 'm':
00427         result = "unsigned long";
00428         break;
00429       case 'x':
00430         result = "long long";
00431         break;
00432       case 'y':
00433         result = "unsigned long long";
00434         break;
00435       case 'n':
00436         result = "__int128";
00437         break;
00438       case 'o':
00439         result = "unsigned __int128";
00440         break;
00441       case 'f':
00442         result = "float";
00443         break;
00444       case 'd':
00445         result = "double";
00446         break;
00447       case 'e':
00448         result = "long double";
00449         break;
00450       case 'g':
00451         result = "__float128";
00452         break;
00453       case 'z':
00454         result = "ellipsis";
00455         break;
00456       }
00457     }
00458     else  {
00459       int   status;
00460       char* realname;
00461       realname = abi::__cxa_demangle(class_name, 0, 0, &status);
00462       if (realname == 0) return class_name;
00463       result = realname;
00464       free(realname);
00466       std::string::size_type pos = result.find(", ");
00467       while( std::string::npos != pos ) {
00468         result.replace( pos , 2 , "," ) ;
00469         pos = result.find(", ");
00470       }
00471     }
00472 #endif
00473   return result;
00474 }

const std::string System::typeinfoName ( const std::type_info  ) 

Get platform independent information about the class type.

Definition at line 352 of file System.cpp.

Referenced by AlgTool::AlgTool(), ApplicationMgr::configure(), Sequencer::decodeNames(), GaudiSequencer::decodeNames(), GaudiException::GaudiException(), GaudiCommon< PBASE >::get(), GaudiHandle< IToolSvc >::getDefaultType(), GaudiCommon< PBASE >::getFastContainer(), Tuples::ItemStore< VALUE >::getItem(), PersistencySvc::getService(), Gaudi::Guards::ExceptionGuard::handle(), TimingAuditor::i_beforeExecute(), TimingAuditor::i_beforeInitialize(), HistogramSvc::i_book(), HepRndm::Engine< TYPE >::initialize(), GslSvc::initialize(), PoolDbCnvSvc::loadConverter(), DataSvc::loadObject(), ConversionSvc::makeCall(), DataTypeInfo::name(), MinimalEventLoopMgr::nextEvent(), GaudiCommon< PBASE >::Print(), StoreExplorerAlg::printObj(), GaudiCommon< PBASE >::printProps(), GaudiCommon< PBASE >::put(), Tuples::TupleObj::put(), ServiceHistory::ServiceHistory(), typeinfoName(), PoolDbCnvFactory< ConcreteConverter, i >::typeName(), GaudiDict::typeName(), NTuple::_DataImp< TYP >::typeName(), and DataSvc::updateObject().

00352                                                                {
00353   return typeinfoName(tinfo.name());
00354 }

unsigned long System::unloadDynamicLib ( ImageHandle  handle  ) 

unload dynamic link library

Definition at line 154 of file System.cpp.

References getLastError(), and getProcedureByName().

00154                                                             {
00155 #ifdef _WIN32
00156   if ( !::FreeLibrary((HINSTANCE)handle) ) {
00157 #elif defined(linux) || defined(__APPLE__)
00158   ::dlclose( handle );
00159   if ( 0 ) {
00160 #elif __hpux
00161   // On HP we have to run finalization ourselves.....
00162   Creator pFinalize = 0;
00163   if ( getProcedureByName(handle, "_fini", &pFinalize) ) {
00164     pFinalize();
00165   }
00166   HMODULE* mod = (HMODULE*)handle;
00167   if ( 0 == ::shl_unload( mod->dsc.handle ) ) {
00168     delete mod;
00169   }
00170   else {
00171 #endif
00172     return getLastError();
00173   }

unsigned long System::unloadDynamicLib ( ImageHandle  handle  ) 

unload dynamic link library

Definition at line 154 of file System.cpp.

References getLastError(), and getProcedureByName().

00154                                                             {
00155 #ifdef _WIN32
00156   if ( !::FreeLibrary((HINSTANCE)handle) ) {
00157 #elif defined(linux) || defined(__APPLE__)
00158   ::dlclose( handle );
00159   if ( 0 ) {
00160 #elif __hpux
00161   // On HP we have to run finalization ourselves.....
00162   Creator pFinalize = 0;
00163   if ( getProcedureByName(handle, "_fini", &pFinalize) ) {
00164     pFinalize();
00165   }
00166   HMODULE* mod = (HMODULE*)handle;
00167   if ( 0 == ::shl_unload( mod->dsc.handle ) ) {
00168     delete mod;
00169   }
00170   else {
00171 #endif
00172     return getLastError();
00173   }

longlong System::upTime ( TimeType  typ = Hour  ) 

Maximum processing time left for this process.

Parameters:
typ Indicator or the unit the time will be returned.
Returns:
Requested value in the indicated units.

Definition at line 110 of file Timing.cpp.

References adjustTime(), currentTime(), microSec, and systemStart().

00110                                        {
00111   static longlong sys_start = 10*systemStart(microSec);
00112   return adjustTime(typ, 10*currentTime(microSec)-sys_start);
00113 }

longlong System::upTime ( TimeType  typ = Hour  ) 

Maximum processing time left for this process.

Parameters:
typ Indicator or the unit the time will be returned.
Returns:
Requested value in the indicated units.

Definition at line 110 of file Timing.cpp.

References adjustTime(), currentTime(), microSec, and systemStart().

00110                                        {
00111   static longlong sys_start = 10*systemStart(microSec);
00112   return adjustTime(typ, 10*currentTime(microSec)-sys_start);
00113 }

longlong System::userTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

CPU user mode time of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 160 of file Timing.cpp.

References adjustTime(), getProcess(), NoFetch, and System::KERNEL_USER_TIMES::UserTime.

Referenced by ChronoEntity::start(), and ChronoEntity::stop().

00160                                                                 {
00161   longlong usertime = 0;
00162   KERNEL_USER_TIMES info;
00163   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00164     usertime = adjustTime(typ, info.UserTime );
00165   }
00166   return usertime;
00167 }

longlong System::userTime ( TimeType  typ = milliSec,
InfoType  fetch = Times,
long  pid = -1 
)

CPU user mode time of process in milli seconds.

Parameters:
typ Indicator or the unit the time will be returned.
fetch Indicator of the information to be fetched. If Fetch_None, the information will not be updated.
pid Process ID of which the information will be returned
Returns:
Requested value in the indicated units.

Definition at line 160 of file Timing.cpp.

References adjustTime(), getProcess(), NoFetch, and System::KERNEL_USER_TIMES::UserTime.

Referenced by ChronoEntity::start(), and ChronoEntity::stop().

00160                                                                 {
00161   longlong usertime = 0;
00162   KERNEL_USER_TIMES info;
00163   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )   {
00164     usertime = adjustTime(typ, info.UserTime );
00165   }
00166   return usertime;
00167 }

long System::virtualMemory ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: priority boost.

Definition at line 213 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::VirtualSize.

00213                                                                       {
00214   VM_COUNTERS info;
00215   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00216     return adjustMemory(unit, info.VirtualSize);
00217   return -2;
00218 }

long System::virtualMemory ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: priority boost.

Definition at line 213 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::VirtualSize.

00213                                                                       {
00214   VM_COUNTERS info;
00215   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00216     return adjustMemory(unit, info.VirtualSize);
00217   return -2;
00218 }

long System::virtualMemoryLimit ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

System Process Limits: Maximum amount of the page file this process is allowed to use.

Definition at line 229 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::QUOTA_LIMITS::PagefileLimit.

00229                                                                            {
00230   QUOTA_LIMITS quota;
00231   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )    {
00232     if ( long(quota.PagefileLimit) == -1 )
00233       return -1;//LONG_MAX;
00234     return adjustMemory(unit, quota.PagefileLimit);
00235   }
00236   return 0;
00237 }

long System::virtualMemoryLimit ( MemoryUnit  unit = kByte,
InfoType  fetch = Quota,
long  pid = -1 
)

System Process Limits: Maximum amount of the page file this process is allowed to use.

Definition at line 229 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::QUOTA_LIMITS::PagefileLimit.

00229                                                                            {
00230   QUOTA_LIMITS quota;
00231   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &quota) )    {
00232     if ( long(quota.PagefileLimit) == -1 )
00233       return -1;//LONG_MAX;
00234     return adjustMemory(unit, quota.PagefileLimit);
00235   }
00236   return 0;
00237 }

long System::virtualMemoryPeak ( MemoryUnit  unit,
InfoType  fetch,
long  pid 
)

Basic Process Information: priority boost.

Definition at line 221 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PeakVirtualSize.

00221                                                                           {
00222   VM_COUNTERS info;
00223   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00224     return adjustMemory(unit, info.PeakVirtualSize);
00225   return -2;
00226 }

long System::virtualMemoryPeak ( MemoryUnit  unit = kByte,
InfoType  fetch = Memory,
long  pid = -1 
)

Basic Process Information: priority boost.

Definition at line 221 of file Memory.cpp.

References adjustMemory(), getProcess(), NoFetch, and System::VM_COUNTERS::PeakVirtualSize.

00221                                                                           {
00222   VM_COUNTERS info;
00223   if ( fetch != NoFetch && getProcess()->query(pid, fetch, &info) )
00224     return adjustMemory(unit, info.PeakVirtualSize);
00225   return -2;
00226 }


Generated at Fri Jul 18 12:11:17 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004