MISYSTEM Class Reference

Container for static methods to access various system and execution environment valuses. More...

#include <mi32/misystem.h>

List of all members.

Classes

class  DISABLE_SUSPEND
 Sentry class to enable/disable system suspend during long non-interactive operations. More...

Public Types

enum  EXECUTEFLAGS { EXECUTEFLAG_None = 0x0000, EXECUTEFLAG_WaitUntilFinished = 0x0001, EXECUTEFLAG_ShowConsole = 0x0002, EXECUTEFLAG_NoWaitForInit = 0x0004 }
enum  PLATFORM {
  PLATFORM_Unknown = 0, PLATFORM_Win32_PreNT = 0x000100, PLATFORM_Win95 = (PLATFORM_Win32_PreNT | 0x01), PLATFORM_Win98 = (PLATFORM_Win32_PreNT | 0x02),
  PLATFORM_WinME = (PLATFORM_Win32_PreNT | 0x03), PLATFORM_Win32_NT = 0x001000, PLATFORM_WinNT = (PLATFORM_Win32_NT | 0x01), PLATFORM_Win2000 = (PLATFORM_Win32_NT | 0x02),
  PLATFORM_WinXP = (PLATFORM_Win32_NT | 0x03), PLATFORM_WinServer2003 = (PLATFORM_Win32_NT | 0x04), PLATFORM_WinVista = (PLATFORM_Win32_NT | 0x05), PLATFORM_WinServer2008 = (PLATFORM_Win32_NT | 0x06),
  PLATFORM_Win7 = (PLATFORM_Win32_NT | 0x07), PLATFORM_WinServer2008_R2 = (PLATFORM_Win32_NT | 0x08), PLATFORM_Unix = 0x002000, PLATFORM_MacOSX = (PLATFORM_Unix | 0x01),
  PLATFORM_LinuxX86 = (PLATFORM_Unix | 0x02), PLATFORM_UnixSun = (PLATFORM_Unix | 0x03), PLATFORM_UnixSGI = (PLATFORM_Unix | 0x04), PLATFORM_UnixIBM = (PLATFORM_Unix | 0x05)
}
enum  PROCESSRESULT {
  PROCESSRESULT_Finished = 0, PROCESSRESULT_ExitError, PROCESSRESULT_ExternalStop, PROCESSRESULT_DiedCoreDump,
  PROCESSRESULT_DiedNoCoreDump
}
enum  RUNMODE { RUNMODE_User, RUNMODE_Job }
typedef UINT64 THREAD_ID

Static Public Member Functions

static void DisableCrashWindow ()
static ERRVALUE ExecuteProcess (const MISTRING &Process, EXECUTEFLAGS ExeFlags=EXECUTEFLAG_None, FastDelegate< void(PTRUINT, PROCESSRESULT)> DelegateOnProcessEnd=0, PTRUINT *ProcessID=0)
static const MISTRINGLISTGetCurrentLanguageSet ()
static THREAD_ID GetCurrentThreadID ()
static MISTRING GetCurrentUserName ()
static MISTRING GetEnvironmentValue (const char *name)
static MISTRING GetHostDetails ()
static MISTRING GetHostName ()
static int GetNumLogicalProcessors ()
static int GetNumPhysicalProcessors ()
static INT64 GetPhysicalMemoryAvailable ()
static INT64 GetPhysicalMemoryTotal ()
static PLATFORM GetPlatform ()
static UINT32 GetProcessID ()
static RUNMODE GetRunMode ()
static CHAR_ENCODING GetSystemEncoding ()
static const char * GetSystemLanguage ()
static UINT32 GetTickCount ()
static UINT32 GetTicksPerSecond ()
static double GetTimerValue ()
static int GetUserThreadLimit (bool IncludeLogicalCores)
static INT64 GetVirtualMemoryAvailable ()
static INT64 GetVirtualMemoryTotal ()
static void Initialize ()
static bool IsMainThread ()
static void KillProcess (int ProcessID)
static const char * LookupISO639_1Code (const char *iso639_2code)
static const char * LookupISO639_2Code (const char *iso639_1code)
static void SetAsMainThread ()
static void SetCurrentLanguageSet (const MISTRINGLIST &iso639)
static ERRVALUE SetCurrentWorkingDirectory (const FILEPATH &filepath)
static void SetEnvironmentValue (const char *name, const char *value)
static void SetRunMode (RUNMODE runmode)
static void SetSuspendDisabled (bool disable)
static void SetUserThreadLimit (int MaxThreads)
static void Sleep (double delay)
static bool Supports64BitFileSystem ()
static ERRVALUE TranslateSystemError (ERRVALUE DftErrCode, INT32 &SystemError)
static void Uninitialize ()

Detailed Description

Container for static methods to access various system and execution environment valuses.


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
EXECUTEFLAG_None 
EXECUTEFLAG_WaitUntilFinished 

Block this thread's execution until the generated process is done.

EXECUTEFLAG_ShowConsole 

Show console on process creation, available for Windows only.

EXECUTEFLAG_NoWaitForInit 

Don't call WaitForInputIdle to wait for process to finish initialization, Windows only.

Enumerator:
PLATFORM_Unknown 
PLATFORM_Win32_PreNT 
PLATFORM_Win95 
PLATFORM_Win98 

Microsoft Windows 95.

PLATFORM_WinME 

Microsoft Windows 98.

PLATFORM_Win32_NT 

Microsoft Windows Me.

PLATFORM_WinNT 
PLATFORM_Win2000 

Microsoft Windows NT 4.

PLATFORM_WinXP 

Microsoft Windows 2000.

PLATFORM_WinServer2003 

Microsoft Windows XP.

PLATFORM_WinVista 

Microsoft Windows Server 2003.

PLATFORM_WinServer2008 

Microsoft Windows Vista.

PLATFORM_Win7 

Microsoft Windows Server 2008.

PLATFORM_WinServer2008_R2 

Microsoft Windows 7.

PLATFORM_Unix 

Microsoft Windows Server 2008 R2.

PLATFORM_MacOSX 
PLATFORM_LinuxX86 
PLATFORM_UnixSun 
PLATFORM_UnixSGI 
PLATFORM_UnixIBM 
Enumerator:
PROCESSRESULT_Finished 
PROCESSRESULT_ExitError 
PROCESSRESULT_ExternalStop 
PROCESSRESULT_DiedCoreDump 
PROCESSRESULT_DiedNoCoreDump 

Process run mode.

Enumerator:
RUNMODE_User 

User (interactive) process (default if not set).

RUNMODE_Job 

Job (batch) process.


Member Function Documentation

static void MISYSTEM::DisableCrashWindow (  )  [static]

Disable dialog that may be displayed when process crashes.

Use with care, as process will simply terminate on crash.

static ERRVALUE MISYSTEM::ExecuteProcess ( const MISTRING Process,
EXECUTEFLAGS  ExeFlags = EXECUTEFLAG_None,
FastDelegate< void(PTRUINT, PROCESSRESULT)>  DelegateOnProcessEnd = 0,
PTRUINT ProcessID = 0 
) [static]

Execute a process with possible additional parameters.

Double quotes are required for the process string and any parameters that have spaces. If called on UNIX systems with EXECUTEFLAG_WaitUntilFinished specified, only one delegate per thread can be assigned. If another delegate is assigned for the same thread, the other is dropped. Windows systems do not have this limitation.

Parameters:
Process Process to execute plus any parameters. If process is not an absolute path, OS process location rules apply.
DelegateOnProcessEnd Called when the process is finished
ProcessID Process ID of the child created RETURNED, if not NULL and EXECUTEFLAG_WaitUntilFinished is not specified and DelegateOnProcessEnd is assigned
static const MISTRINGLIST& MISYSTEM::GetCurrentLanguageSet (  )  [static]

Get the current language set for the calling thread.

Depending on the situation, there may be more than one language selected in the order of first language prefered. The default language set order is: 1. The code stored in the user's tntproc.ini file, if the entry exists. 2. The code returned by GetSystemLanguage(). 2. English code "enu".

Returns:
ISO 639-2 three character language codes or ISO 639-1 two character language codes with possible ISO 3166 country codes
static THREAD_ID MISYSTEM::GetCurrentThreadID (  )  [static]

Get current thread ID.

Returns:
The ID of the thread that calls this method
static MISTRING MISYSTEM::GetCurrentUserName (  )  [static]

Get current user name.

Returns:
MISTRING containing name, will be 'UnknownUser' if cannot determine name.
static MISTRING MISYSTEM::GetEnvironmentValue ( const char *  name  )  [static]

Get value of named environment variable.

Returns:
MISTRING containing value, will be empty if no matching environment variable.
Parameters:
name Environment variable name
static MISTRING MISYSTEM::GetHostDetails (  )  [static]

Get host computer details.

Returns multi-line string which may include OS name, version, service pack, processor, total physical and virtual memory, and other non-user-specific information.

static MISTRING MISYSTEM::GetHostName (  )  [static]

Get host computer name.

Returns:
MISTRING containing computer (non DNS) name, will be 'LocalHost' if cannot determine name.
static int MISYSTEM::GetNumLogicalProcessors (  )  [static]

Get the number of logical processors.

Returns:
the number of logical processors in the system, this does include hyperthreaded processors Return value will always be at least the value returned by GetNumPhysicalProcessors. Will return one if the number of processors cannot be determined.
static int MISYSTEM::GetNumPhysicalProcessors (  )  [static]

Get the number of physical processors.

Returns:
the number of actual physical processors in the system, this does not include hyperthreaded processors Will return zero if the number of physical processors cannot be determined.
static INT64 MISYSTEM::GetPhysicalMemoryAvailable (  )  [static]

Get amount of available physical memory.

Returns:
Number of bytes, -1 if unsupported, < -1 if error.
static INT64 MISYSTEM::GetPhysicalMemoryTotal (  )  [static]

Get amount of total physical memory.

Returns:
Number of bytes, -1 if unsupported, < -1 if error.
static PLATFORM MISYSTEM::GetPlatform (  )  [static]

Get platform.

static UINT32 MISYSTEM::GetProcessID (  )  [static]

Get the numeric ID of the current process.

static RUNMODE MISYSTEM::GetRunMode (  )  [static]

Get process run mode.

static CHAR_ENCODING MISYSTEM::GetSystemEncoding (  )  [static]

Get the system encoding that is used in filenames and other system strings For Windows and MAC, they are static, for LINUX and SUN, it depends on the current locale setting.

Returns:
The system encoding
static const char* MISYSTEM::GetSystemLanguage (  )  [static]

Get the language setup for the system (set via the current user).

Returns:
The ISO639-1 two character language code for the current user with the ISO3166 county/region two character name. (Eg: en-US)
static UINT32 MISYSTEM::GetTickCount (  )  [static]

Returns a simple clock tick of unknown starting time.

static UINT32 MISYSTEM::GetTicksPerSecond (  )  [static]

Get number of clock ticks per second.

static double MISYSTEM::GetTimerValue (  )  [static]

Return 'timer' value.

Precision of timer is system-dependent, ranging from 1ms and 100ns.

Returns:
Number of seconds from arbitrary starting time.
static int MISYSTEM::GetUserThreadLimit ( bool  IncludeLogicalCores  )  [static]

Get user preference for thread limit.

If no thread limit set, return value is based on number of processor cores, otherwise will return smalller of user limit and number of cores.

Parameters:
IncludeLogicalCores Include logical (hyperthreading) cores if any
static INT64 MISYSTEM::GetVirtualMemoryAvailable (  )  [static]

Get amount of available virtual memory.

The return value may change if the OS supports dynamic page/swap file allocation.

Returns:
Number of bytes, -1 if unsupported, < -1 if error.
static INT64 MISYSTEM::GetVirtualMemoryTotal (  )  [static]

Get total amount of virtual memory.

The return value may change if the OS supports dynamic page/swap file allocation.

Returns:
Number of bytes, -1 if unsupported, < -1 if error.
static void MISYSTEM::Initialize (  )  [static]

Initialize system.

static bool MISYSTEM::IsMainThread (  )  [static]

Determine if current thread is set as "main" thread.

Typically the "user interface" is run in the main thread.

static void MISYSTEM::KillProcess ( int  ProcessID  )  [static]

Kill process by pid.

static const char* MISYSTEM::LookupISO639_1Code ( const char *  iso639_2code  )  [static]

Given an ISO639-2 three character language code, return the equivalent ISO639-1 two character language code.

Returns:
The ISO639-1 two character language code or NULL if one is not found
Parameters:
iso639_2code ISO639-2 three character language code
static const char* MISYSTEM::LookupISO639_2Code ( const char *  iso639_1code  )  [static]

Given an ISO639-1 two character language code, return the equivalent ISO639-2 three character language code The returned ISO639-2 code may have two sets of codes separated by a '/'.

Returns:
The ISO639-2 three character language code or NULL if one is not found
Parameters:
iso639_1code ISO639-1 two character language code
static void MISYSTEM::SetAsMainThread (  )  [static]

Set current thread as "main thread".

static void MISYSTEM::SetCurrentLanguageSet ( const MISTRINGLIST iso639  )  [static]

Set the current language set for the calling thread.

If there is more than one language listed, then the order is of first language prefered.

Parameters:
iso639 ISO 639-2 three character language code or ISO 639-1 two character language code with a possible ISO 3166 country code list
static ERRVALUE MISYSTEM::SetCurrentWorkingDirectory ( const FILEPATH filepath  )  [static]

Set the current working directory.

Note, to get the current working directory, construct a FILEPATH with FILEPATH::PATHTYPE_Current.

static void MISYSTEM::SetEnvironmentValue ( const char *  name,
const char *  value 
) [static]

Set value of named environment variable (char* value).

Parameters:
name Environment variable name
value Value to set
static void MISYSTEM::SetRunMode ( RUNMODE  runmode  )  [static]

Set process "run" mode.

Parameters:
runmode Run mode
static void MISYSTEM::SetSuspendDisabled ( bool  disable  )  [static]

Enable or prevent system processor from entering suspended / sleeping state.

Keeps counter so each time is disabled must be matched by call to enable. Initial state is to enable suspend. May not be supported on all platforms.

Parameters:
disable True to disable suspend, false to enable
static void MISYSTEM::SetUserThreadLimit ( int  MaxThreads  )  [static]

Set user preference for thread limit.

Intended to allow user to limit number of threads below default for evaluating performance.

Parameters:
MaxThreads Maximum threads to return from GetUserThreadLimit
static void MISYSTEM::Sleep ( double  delay  )  [static]

Delay for specified time.

Parameters:
delay Time to delay in seconds
static bool MISYSTEM::Supports64BitFileSystem (  )  [static]

Determine if system supports 64-bit filesystems.

static ERRVALUE MISYSTEM::TranslateSystemError ( ERRVALUE  DftErrCode,
INT32 SystemError 
) [static]

Translate OS error code to MicroImages error code Does NOT do a SetErrPosn() on the error code, that is up to the caller.

Parameters:
DftErrCode Default error code to use if system error not specifically handled
SystemError Operating sytem error RETURNED
static void MISYSTEM::Uninitialize (  )  [static]

Uninitialize system.


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

Generated on Sun Oct 7 21:33:40 2012 for TNTsdk 2012 by  doxygen 1.6.1