The Gaudi Framework  master (e039bf8c)
Loading...
Searching...
No Matches
System.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
13#include <GaudiKernel/Kernel.h>
15#include <GaudiKernel/Timing.h>
16#include <string>
17#include <typeinfo>
18#include <vector>
19
20#ifdef __linux
21# include <pthread.h>
22# ifndef __APPLE__
23# include <execinfo.h>
24# endif
25#endif
26
35namespace System {
37 typedef void* ImageHandle;
39 typedef void* ProcessHandle;
41 typedef unsigned long ( *EntryPoint )( const unsigned long iid, void** ppvObject );
43 typedef void* ( *Creator )();
45 GAUDI_API unsigned long loadDynamicLib( const std::string& name, ImageHandle* handle );
47 GAUDI_API unsigned long unloadDynamicLib( ImageHandle handle );
49 GAUDI_API unsigned long getProcedureByName( ImageHandle handle, const std::string& name, EntryPoint* pFunction );
51 GAUDI_API unsigned long getProcedureByName( ImageHandle handle, const std::string& name, Creator* pFunction );
53 GAUDI_API unsigned long getLastError();
55 GAUDI_API const std::string getLastErrorString();
57 GAUDI_API const std::string getErrorString( unsigned long error );
59 GAUDI_API const std::string typeinfoName( const std::type_info& );
60 GAUDI_API const std::string typeinfoName( const char* );
62 GAUDI_API const std::string& hostName();
64 GAUDI_API const std::string& osName();
66 GAUDI_API const std::string& osVersion();
68 GAUDI_API const std::string& machineType();
70 GAUDI_API const std::string& accountName();
74 GAUDI_API long argc();
76 GAUDI_API const std::vector<std::string> cmdLineArgs();
78 GAUDI_API char** argv();
80 GAUDI_API std::string getEnv( const char* var );
83 GAUDI_API bool getEnv( const char* var, std::string& value );
84 inline bool getEnv( const std::string& var, std::string& value ) { return getEnv( var.c_str(), value ); }
86 GAUDI_API std::vector<std::string> getEnv();
92 GAUDI_API int setEnv( const std::string& name, const std::string& value, int overwrite = 1 );
94 GAUDI_API bool isEnvSet( const char* var );
95#ifdef __linux
97 typedef pthread_t ThreadHandle;
99 inline ThreadHandle threadSelf() { return pthread_self(); }
100#else
102 typedef void* ThreadHandle;
104 inline ThreadHandle threadSelf() { return (void*)0; }
105#endif
106 GAUDI_API int backTrace( void** addresses, const int depth );
107 GAUDI_API bool backTrace( std::string& btrace, const int depth, const int offset = 0 );
108 GAUDI_API bool getStackLevel( void* addresses, void*& addr, std::string& fnc, std::string& lib );
109} // namespace System
#define GAUDI_API
Definition Kernel.h:49
Note: OS specific details for environment resolution.
Definition Environment.h:25
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
Definition System.cpp:393
GAUDI_API const std::string & osName()
OS name.
Definition System.cpp:265
GAUDI_API int backTrace(void **addresses, const int depth)
Definition System.cpp:357
void *(* Creator)()
Definition of the "generic" DLL entry point function.
Definition System.h:43
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
Definition System.cpp:334
unsigned long(* EntryPoint)(const unsigned long iid, void **ppvObject)
Definition of the "generic" DLL entry point function.
Definition System.h:41
GAUDI_API const std::string & machineType()
Machine type.
Definition System.cpp:277
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition System.cpp:109
ThreadHandle threadSelf()
thread handle "accessor"
Definition System.h:104
GAUDI_API long numCmdLineArgs()
Number of arguments passed to the commandline.
Definition System.cpp:289
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition System.cpp:228
GAUDI_API unsigned long unloadDynamicLib(ImageHandle handle)
unload dynamic link library
Definition System.cpp:154
GAUDI_API unsigned long getProcedureByName(ImageHandle handle, const std::string &name, EntryPoint *pFunction)
Get a specific function defined in the DLL.
Definition System.cpp:175
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:254
void * ImageHandle
Definition of an image handle.
Definition ModuleInfo.h:25
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
Definition System.cpp:341
GAUDI_API const std::string & hostName()
Host name.
Definition System.cpp:259
GAUDI_API const std::string & accountName()
User login name.
Definition System.cpp:283
GAUDI_API unsigned long getLastError()
Get last system known error.
Definition System.cpp:222
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call....
Definition System.cpp:292
void * ProcessHandle
Definition of the process handle.
Definition ModuleInfo.h:27
GAUDI_API const std::string getErrorString(unsigned long error)
Retrieve error code as string for a given error.
Definition System.cpp:234
GAUDI_API const std::vector< std::string > cmdLineArgs()
Command line arguments including executable name as arg[0] as vector of strings.
Definition System.cpp:295
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
Definition System.cpp:425
void * ThreadHandle
A Thread handle.
Definition System.h:102
GAUDI_API char ** argv()
char** command line arguments including executable name as arg[0]; You may not modify them!
Definition System.cpp:301
GAUDI_API const std::string & osVersion()
OS version.
Definition System.cpp:271