PixelLightAPI  .
Public Member Functions | Static Public Member Functions
PLCore::System Class Reference

Provides access to system and platform functions. More...

#include <System.h>

List of all members.

Public Member Functions

PLCORE_API String GetInfo () const
 Returns relevant system information in one string.
PLCORE_API bool IsLittleEndian () const
 Detects the current machine's endian ("byte order")
String GetPlatform () const
 Returns the name of the platform.
PLCORE_API String GetPlatformArchitecture () const
 Returns the platform architecture.
PLCORE_API uint32 GetPlatformBitArchitecture () const
 Returns the platform bit architecture.
String GetOS () const
 Returns the name and version of the operating system.
char GetSeparator () const
 Returns the directory separator used by the operation system.
String GetSharedLibraryPrefix () const
 Returns the shared library filename prefix used by the operation system.
String GetSharedLibraryExtension () const
 Returns the shared library file extension used by the operation system.
uint32 GetCPUMhz () const
 Get the CPU MHz.
String GetComputerName () const
 Returns the name of the computer.
String GetUserName () const
 Returns the current user name.
String GetUserHomeDir () const
 Get home directory of the current user.
String GetUserDataDir () const
 Get data directory of the current user.
String GetDataDirName (const String &sName) const
 Get name of data directory for given application name.
String GetExecutableFilename () const
 Get absolute path of application executable.
String GetEnvironmentVariable (const String &sName) const
 Reads an environment variable.
bool SetEnvironmentVariable (const String &sName, const String &sValue) const
 Writes an environment variable.
void DeleteEnvironmentVariable (const String &sName) const
 Deletes an environment variable.
bool Execute (const String &sCommand, const String &sParameters, const String &sWorkingDir="") const
 Executes a system command (create a new process)
String GetLocaleLanguage () const
 Returns the current program locale language information.
String GetCurrentDir () const
 Returns the current directory.
bool SetCurrentDir (const String &sPath)
 Sets the current directory.
ThreadGetMainThread () const
 Returns a pointer to the main thread.
ThreadGetCurrentThread () const
 Returns a pointer to the current thread.
void Exit (int nReturn)
 Exit the application immediately.
const ConsoleGetConsole () const
 Returns the console instance.
void UrgentMessage (const String &sMessage) const
 Primitive way (e.g. by using a message box) to be able to tell the user that something went terrible wrong.
Time GetTime () const
 Returns the current date and time.
uint64 GetMilliseconds () const
 Returns the number of milliseconds since the system was started.
uint64 GetMicroseconds () const
 Retrieves the number of microseconds since the system was started.
void Sleep (uint64 nMilliseconds) const
 Suspend the current thread for a specified time period.
void Yield () const
 Yields the rest of the current threads time slice.
float GetPercentageOfUsedPhysicalMemory () const
 Returns an approximation of the percentage of used physical memory (0.0-100.0)
uint64 GetTotalPhysicalMemory () const
 Returns the total physical memory in bytes.
uint64 GetFreePhysicalMemory () const
 Returns the current free physical memory in bytes.
uint64 GetTotalVirtualMemory () const
 Returns the total virtual memory in bytes.
uint64 GetFreeVirtualMemory () const
 Returns the current free virtual memory in bytes.

Static Public Member Functions

static PLCORE_API SystemGetInstance ()
static PLCORE_API bool HasInstance ()

Detailed Description

Provides access to system and platform functions.

Note:
  • Implementation of the bridge design pattern, this class is the abstraction

Member Function Documentation

static PLCORE_API System* PLCore::System::GetInstance ( ) [static]
static PLCORE_API bool PLCore::System::HasInstance ( ) [static]
PLCORE_API String PLCore::System::GetInfo ( ) const

Returns relevant system information in one string.

Returns:
Information string
Remarks:
The returned information are
  • PLCore version information
  • PLCore build information
  • Endian
  • Platform
  • Operating system version
PLCORE_API bool PLCore::System::IsLittleEndian ( ) const

Detects the current machine's endian ("byte order")

Returns:
'true' if the current machine is using 'Little Endian First', (LSB (least significant byte), also known as 'Intel-Format') 'false' if the current machine is using 'Big Endian First', (MSB (most significant byte), also known as 'Motorola-Format')
Note:
  • PixelLight is using 'Little Endian First' for it's binary file formats and so on
String PLCore::System::GetPlatform ( ) const [inline]

Returns the name of the platform.

Returns:
Platform string (for instance 'Windows' for Windows, 'Linux' for Linux and so on)

Returns the platform architecture.

Returns:
Platform architecture (for instance 'x86', 'x64', 'armeabi', 'armeabi-v7a' and so on)
PLCORE_API uint32 PLCore::System::GetPlatformBitArchitecture ( ) const

Returns the platform bit architecture.

Returns:
Platform bit architecture (for instance '32' for x86, '64' for x64)
String PLCore::System::GetOS ( ) const [inline]

Returns the name and version of the operating system.

Returns:
OS information string (for instance 'Windows 7 Service Pack 1 (Build 7601)')
char PLCore::System::GetSeparator ( ) const [inline]

Returns the directory separator used by the operation system.

Returns:
The directory separator used by the operation system (e.g. '/' on Linux, '\' on Windows)

Returns the shared library filename prefix used by the operation system.

Returns:
The shared library filename prefix used by the operation system (e.g. 'lib' as in 'libPLCore.so' on Linux, no prefix as in 'PLCore.dll' on Windows)

Returns the shared library file extension used by the operation system.

Returns:
The shared library file extension used by the operation system (e.g. 'so' on Linux, 'dll' on Windows)
uint32 PLCore::System::GetCPUMhz ( ) const [inline]

Get the CPU MHz.

Returns:
CPU MHz

Returns the name of the computer.

Returns:
Computer name
String PLCore::System::GetUserName ( ) const [inline]

Returns the current user name.

Returns:
User name

Get home directory of the current user.

Returns:
The home directory of the current user (native path style)
Remarks:
Examples on different systems:
  • Linux: /home/<username>
  • Windows XP: C: and Settings<Username>
  • Windows 7: C:<UserName>

Get data directory of the current user.

Returns:
The data directory of the current user (native path style)
Remarks:
Examples on different systems:
  • Linux: /home/<username>
  • Windows XP: C: and Settings<Username> Data
  • Windows 7: C:<UserName>
String PLCore::System::GetDataDirName ( const String sName) const [inline]

Get name of data directory for given application name.

Parameters:
[in]sNameApplication name
Returns:
Name of data directory in native style of used OS
Remarks:
Examples on different systems:
  • Linux: GetDataDirName("PixelLight") -> ".pixellight"
  • Windows: GetDataDirName("PixelLight") -> "PixelLight"

Get absolute path of application executable.

Returns:
Path to executable (native path style, e.g. on Windows: 'C:.exe')
Note:
  • Application executable = currently running process
String PLCore::System::GetEnvironmentVariable ( const String sName) const [inline]

Reads an environment variable.

Parameters:
[in]sNameName of the environment variable to read
Returns:
Content of the variable
bool PLCore::System::SetEnvironmentVariable ( const String sName,
const String sValue 
) const [inline]

Writes an environment variable.

Parameters:
[in]sNameName of the environment variable to write
[in]sValueValue to write into the variable
Returns:
'true' if the variable has been set successfully, else 'false'
void PLCore::System::DeleteEnvironmentVariable ( const String sName) const [inline]

Deletes an environment variable.

Parameters:
[in]sNameName of the environment variable to delete
bool PLCore::System::Execute ( const String sCommand,
const String sParameters,
const String sWorkingDir = "" 
) const [inline]

Executes a system command (create a new process)

Parameters:
[in]sCommandCommand to execute
[in]sParametersParameters to pass to the command
[in]sWorkingDirWorking directory in which to execute the command
Returns:
'true' if the command has been executed successfully, else 'false'

Returns the current program locale language information.

Remarks:
Internally 'setlocale' is used to collect the current program locale information - but only the 'language' information is returned as string. For instance, if the current locale is 'English_USA.1252', 'English' is returned, if the locale is 'French_France.1252', just 'French' is returned and so on. This information can for instance be used to set a correct default language within the localization system of PixelLight.
Returns:
The current program locale language information

Returns the current directory.

Returns:
Path to the current directory as the OS provided it (native path style)
Note:
  • In case of an internally empty string you will receive "." in order to make it possible to add e.g. "/Data" and still end up in a valid path
  • On Windows for example "C:\Programs\App"
bool PLCore::System::SetCurrentDir ( const String sPath) [inline]

Sets the current directory.

Parameters:
[in]sPathPath to the current directory
Returns:
'true', if all went fine, else 'false'
Note:
  • Whenever possible, do not manipulate the current directory, this may backfire when you don't expect it
Thread * PLCore::System::GetMainThread ( ) const [inline]

Returns a pointer to the main thread.

Returns:
Main thread (assumed to be never a null pointer!)

Returns a pointer to the current thread.

Returns:
Current thread (assumed to be never a null pointer!)
void PLCore::System::Exit ( int  nReturn) [inline]

Exit the application immediately.

Parameters:
[in]nReturnReturn value
const Console & PLCore::System::GetConsole ( ) const [inline]

Returns the console instance.

Returns:
The console instance
void PLCore::System::UrgentMessage ( const String sMessage) const [inline]

Primitive way (e.g. by using a message box) to be able to tell the user that something went terrible wrong.

Parameters:
[in]sMessageMessage to show
Remarks:
Do not misuse this method in order to communicate with the user on a regular basis. This method does only exist to be able to tell the user that something went terrible wrong. There are situations were one can't use a log file, command line or something like this. Even when using e.g. a log file to write out error information - an application may e.g. just close directly after it's start without any further information and the user may even think that the application didn't start in the first place for an unknown reason. In such a situation, it's polite to inform the user that something went terrible wrong and providing a short hint how the issue may be solved. This method wasn't named "MessageBox()" by intend - because such a feature may not be available on the used platform or is handled in another way as a normal MS Windows message box.
Time PLCore::System::GetTime ( ) const [inline]

Returns the current date and time.

Returns:
Date and time string
uint64 PLCore::System::GetMilliseconds ( ) const [inline]

Returns the number of milliseconds since the system was started.

Returns:
Number of milliseconds elapsed since the system was started
uint64 PLCore::System::GetMicroseconds ( ) const [inline]

Retrieves the number of microseconds since the system was started.

Returns:
Number of microseconds elapsed since the system was started
void PLCore::System::Sleep ( uint64  nMilliseconds) const [inline]

Suspend the current thread for a specified time period.

Parameters:
[in]nMillisecondsNumber of milliseconds to sleep, should not be 0 because the behavior is implementation dependent (use 'Yield()' instead)
void PLCore::System::Yield ( ) const [inline]

Yields the rest of the current threads time slice.

Remarks:
Yields the rest of the threads time slice so another active thread of equal or higher priority waiting for processor time can run. Note that this function may return immediately and the behavior is in general not exactly predictable. So, use this function to give the processor just a hint that you are willed to give processor time away.

Returns an approximation of the percentage of used physical memory (0.0-100.0)

Returns:
An approximation of the percentage of used physical memory
uint64 PLCore::System::GetTotalPhysicalMemory ( ) const [inline]

Returns the total physical memory in bytes.

Returns:
The total physical memory in bytes
uint64 PLCore::System::GetFreePhysicalMemory ( ) const [inline]

Returns the current free physical memory in bytes.

Returns:
The current free physical memory in bytes
uint64 PLCore::System::GetTotalVirtualMemory ( ) const [inline]

Returns the total virtual memory in bytes.

Returns:
The total virtual memory in bytes
uint64 PLCore::System::GetFreeVirtualMemory ( ) const [inline]

Returns the current free virtual memory in bytes.

Returns:
The current free virtual memory in bytes

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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:16
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported