KFoundation  v2.1
A Better Foundation Library for C++
 All Classes Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
kfoundation::System Class Reference

Provides a cross-platform way to access sytsem features. More...

#include <kfoundation/System.h>

Public Types

enum  operating_system_t {
  LINUX, FREE_BSD, SOLARIS, APPLE_OS_X,
  MACH, UNSUPPORTED
}
 Operating system type. More...
 

Static Public Member Functions

static Ref< PathgetExePath ()
 Returns executable path for the current process. More...
 
static Ref< PathgetCurrentWorkingDirectory ()
 Returns the current working directory.
 
static bool isBigEndian ()
 Used to check if the current platform is big-endian.
 
static RefConst< UString > demangle (RefConst< UString > symbol)
 Demangles a C++ ABI symbol into a human readable one.
 
static Ref< UString > resolveSymbolName (void *ptr)
 Given pointer to a symbol, returns its name.
 
static Ref< UString > getLastSystemError ()
 Returns the human-readable description of the last system error as indicated by errno register.
 
static operating_system_t getOperatingSystem ()
 Return type of the undelying operating system.
 
static Ref< LoggergetLogger ()
 Returns the default system logger.
 
static void sleep (const kf_int32_t msecs)
 Causes the current threed to sleep for the given number of miliseconds. More...
 
static int exec (const char *command, char **args, kf_int32_t argc)
 Executes the given command with the given set of arguments. More...
 
static MasterMemoryManagergetMasterMemoryManager ()
 Returns reference to the master memory manager.
 
static kf_int64_t getCurrentTimeInMiliseconds ()
 Returns the current time in miliseconds from the standard origin time. More...
 
static kf_int32_t getPid ()
 Returns the process id for this process.
 
static kf_int16_t getNumberOfCpuCores ()
 Returns the number of CPU cores on this machine.
 
static void exit (kf_int32_t code=0)
 Immidiately terminated the program with the given exit code. More...
 
static void exitAfterAllThreads ()
 Waits for all child threads to terminate, then terminates this process with exit code 0.
 

Static Public Attributes

static const StaticRef
< PrintWriter
VOID
 PrintWriter to "void"; it simply discards everything written to it. More...
 
static const StaticRef
< PrintWriter
OUT
 PrintWriter to the standard output pipe. More...
 
static const StaticRef
< PrintWriter
ERR
 PrintWriter to the standard error output pipe. More...
 
static const StaticRef
< InputStream
IN = new StandardInputStreamAdapter(std::cin)
 InputStream from standard input pipe. More...
 

Detailed Description

Provides a cross-platform way to access sytsem features.

It cannot be instantiated.

Member Enumeration Documentation

Operating system type.

Enumerator
LINUX 

Linux.

FREE_BSD 

Free BSD.

SOLARIS 

Solaris.

APPLE_OS_X 

Apple Mac OS X.

MACH 

Mach.

UNSUPPORTED 

Other / Unsupported.

Member Function Documentation

int kfoundation::System::exec ( const char *  command,
char **  args,
kf_int32_t  argc 
)
static

Executes the given command with the given set of arguments.

Parameters
commandThe command to be executed.
argsAn array of C strings, each containing a signle argument.
argcThe number of elements in args.
void kfoundation::System::exit ( kf_int32_t  code = 0)
static

Immidiately terminated the program with the given exit code.

Default value is 0.

kf_int64_t kfoundation::System::getCurrentTimeInMiliseconds ( )
static

Returns the current time in miliseconds from the standard origin time.

The origin time is usually midnigh January 1, 1970 UTC.

Ref< Path > kfoundation::System::getExePath ( )
static

Returns executable path for the current process.

Symlinks are resolved internally.

void kfoundation::System::sleep ( const kf_int32_t  msecs)
static

Causes the current threed to sleep for the given number of miliseconds.

Most platforms provide sleep() which works with 1-second resolution, and usleep() which works with 1-microsecond resolution. System::sleep() provides milisecond resolution which makes sense in most devices, and has the same interface as Java.System.sleep(). Can be used in conjunction with System::getCurrentTimeInMiliseconds() without the fuss of timeval struct.

Parameters
msecsThe number of miliseconds to sleep.

Member Data Documentation

const StaticRef< PrintWriter > kfoundation::System::ERR
static
Initial value:
= new PrintWriter(
StaticRef<OutputStream>(new StandardOutputStreamAdapter(std::cerr)))

PrintWriter to the standard error output pipe.

const StaticRef< InputStream > kfoundation::System::IN = new StandardInputStreamAdapter(std::cin)
static

InputStream from standard input pipe.

const StaticRef< PrintWriter > kfoundation::System::OUT
static
Initial value:
= new PrintWriter(
StaticRef<OutputStream>(new StandardOutputStreamAdapter(std::cout)))

PrintWriter to the standard output pipe.

const StaticRef< PrintWriter > kfoundation::System::VOID
static
Initial value:
= new PrintWriter(
StaticRef<OutputStream>(new VoidOutputStream()))

PrintWriter to "void"; it simply discards everything written to it.


The documentation for this class was generated from the following files: