Colobot
Public Member Functions | Static Public Member Functions | List of all members
CSystemUtils Class Referenceabstract

Platform-specific utils. More...

#include <src/common/system/system.h>

Inheritance diagram for CSystemUtils:
Inheritance graph
[legend]

Public Member Functions

virtual void Init ()=0
 Performs platform-specific initialization. More...
 
virtual SystemDialogResult SystemDialog (SystemDialogType, const std::string &title, const std::string &message)=0
 Displays a system dialog. More...
 
TEST_VIRTUAL SystemDialogResult ConsoleSystemDialog (SystemDialogType type, const std::string &title, const std::string &message)
 Displays a fallback system dialog using console. More...
 
TEST_VIRTUAL SystemTimeStampCreateTimeStamp ()
 Creates a new time stamp object. More...
 
TEST_VIRTUAL void DestroyTimeStamp (SystemTimeStamp *stamp)
 Destroys a time stamp object. More...
 
TEST_VIRTUAL void CopyTimeStamp (SystemTimeStamp *dst, SystemTimeStamp *src)
 Copies the time stamp from src to dst. More...
 
virtual void InterpolateTimeStamp (SystemTimeStamp *dst, SystemTimeStamp *a, SystemTimeStamp *b, float i)=0
 Interpolates between two timestamps. If i=0 then dst=a. If i=1 then dst=b. If i=0.5 then dst is halfway between. More...
 
virtual void GetCurrentTimeStamp (SystemTimeStamp *stamp)=0
 Returns a time stamp associated with current time. More...
 
TEST_VIRTUAL float TimeStampDiff (SystemTimeStamp *before, SystemTimeStamp *after, SystemTimeUnit unit=STU_SEC)
 Returns a difference between two timestamps in given time unit. More...
 
virtual long long TimeStampExactDiff (SystemTimeStamp *before, SystemTimeStamp *after)=0
 Returns the exact (in nanosecond units) difference between two timestamps. More...
 
virtual std::string GetBasePath ()
 Returns the path where the executable binary is located (ends with the path separator) More...
 
virtual std::string GetDataPath ()
 Returns the data path (containing textures, levels, helpfiles, etc) More...
 
virtual std::string GetLangPath ()
 Returns the translations path. More...
 
virtual std::string GetSaveDir ()
 Returns the save dir location. More...
 
virtual std::string GetEnvVar (const std::string &name)
 Returns the environment variable with the given name or an empty string if it does not exist. More...
 
virtual bool OpenPath (const std::string &path)
 Opens a path with default file browser. More...
 
virtual bool OpenWebsite (const std::string &url)
 Opens a website with default web browser. More...
 
virtual void Usleep (int usecs)=0
 Sleep for given amount of microseconds. More...
 

Static Public Member Functions

static std::unique_ptr< CSystemUtilsCreate ()
 Creates system utils for specific platform. More...
 

Detailed Description

Platform-specific utils.

This class provides system-specific utilities like displaying user dialogs and querying system timers for exact timestamps.

Member Function Documentation

◆ Create()

std::unique_ptr< CSystemUtils > CSystemUtils::Create ( )
static

Creates system utils for specific platform.

◆ Init()

virtual void CSystemUtils::Init ( )
pure virtual

Performs platform-specific initialization.

Implemented in CSystemUtilsWindows, CSystemUtilsOther, CSystemUtilsMacOSX, and CSystemUtilsLinux.

◆ SystemDialog()

virtual SystemDialogResult CSystemUtils::SystemDialog ( SystemDialogType  ,
const std::string &  title,
const std::string &  message 
)
pure virtual

Displays a system dialog.

Implemented in CSystemUtilsWindows, CSystemUtilsOther, and CSystemUtilsLinux.

◆ ConsoleSystemDialog()

SystemDialogResult CSystemUtils::ConsoleSystemDialog ( SystemDialogType  type,
const std::string &  title,
const std::string &  message 
)

Displays a fallback system dialog using console.

◆ CreateTimeStamp()

SystemTimeStamp * CSystemUtils::CreateTimeStamp ( )

Creates a new time stamp object.

◆ DestroyTimeStamp()

void CSystemUtils::DestroyTimeStamp ( SystemTimeStamp stamp)

Destroys a time stamp object.

◆ CopyTimeStamp()

void CSystemUtils::CopyTimeStamp ( SystemTimeStamp dst,
SystemTimeStamp src 
)

Copies the time stamp from src to dst.

◆ InterpolateTimeStamp()

virtual void CSystemUtils::InterpolateTimeStamp ( SystemTimeStamp dst,
SystemTimeStamp a,
SystemTimeStamp b,
float  i 
)
pure virtual

Interpolates between two timestamps. If i=0 then dst=a. If i=1 then dst=b. If i=0.5 then dst is halfway between.

Implemented in CSystemUtilsWindows, CSystemUtilsOther, and CSystemUtilsLinux.

◆ GetCurrentTimeStamp()

virtual void CSystemUtils::GetCurrentTimeStamp ( SystemTimeStamp stamp)
pure virtual

Returns a time stamp associated with current time.

Implemented in CSystemUtilsWindows, CSystemUtilsOther, and CSystemUtilsLinux.

◆ TimeStampDiff()

float CSystemUtils::TimeStampDiff ( SystemTimeStamp before,
SystemTimeStamp after,
SystemTimeUnit  unit = STU_SEC 
)

Returns a difference between two timestamps in given time unit.

The difference is after - before.

◆ TimeStampExactDiff()

virtual long long CSystemUtils::TimeStampExactDiff ( SystemTimeStamp before,
SystemTimeStamp after 
)
pure virtual

Returns the exact (in nanosecond units) difference between two timestamps.

The difference is after - before.

Implemented in CSystemUtilsWindows, CSystemUtilsOther, and CSystemUtilsLinux.

◆ GetBasePath()

std::string CSystemUtils::GetBasePath ( )
virtual

Returns the path where the executable binary is located (ends with the path separator)

◆ GetDataPath()

std::string CSystemUtils::GetDataPath ( )
virtual

Returns the data path (containing textures, levels, helpfiles, etc)

Reimplemented in CSystemUtilsMacOSX.

◆ GetLangPath()

std::string CSystemUtils::GetLangPath ( )
virtual

Returns the translations path.

Reimplemented in CSystemUtilsMacOSX.

◆ GetSaveDir()

std::string CSystemUtils::GetSaveDir ( )
virtual

Returns the save dir location.

Reimplemented in CSystemUtilsWindows, CSystemUtilsMacOSX, and CSystemUtilsLinux.

◆ GetEnvVar()

std::string CSystemUtils::GetEnvVar ( const std::string &  name)
virtual

Returns the environment variable with the given name or an empty string if it does not exist.

Reimplemented in CSystemUtilsWindows, CSystemUtilsMacOSX, and CSystemUtilsLinux.

◆ OpenPath()

bool CSystemUtils::OpenPath ( const std::string &  path)
virtual

Opens a path with default file browser.

Returns
true if successful

Reimplemented in CSystemUtilsWindows, CSystemUtilsMacOSX, and CSystemUtilsLinux.

◆ OpenWebsite()

bool CSystemUtils::OpenWebsite ( const std::string &  url)
virtual

Opens a website with default web browser.

Returns
true if successful

Reimplemented in CSystemUtilsWindows, CSystemUtilsMacOSX, and CSystemUtilsLinux.

◆ Usleep()

virtual void CSystemUtils::Usleep ( int  usecs)
pure virtual

Sleep for given amount of microseconds.

Implemented in CSystemUtilsWindows, CSystemUtilsOther, CSystemUtilsMacOSX, and CSystemUtilsLinux.


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