CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

sysfunc.h File Reference

Common system functions. More...

#include <stdarg.h>
#include <stdio.h>
#include "csextern.h"
#include "iutil/cfgfile.h"

Go to the source code of this file.

System functions

bool csDefaultRunLoop (iObjectRegistry *)
 Implements a default run-loop for stand-alone applications.
int csFPrintf (FILE *file, const char *str,...)
 CS version of fprintf (file, str, .
int csFPrintfV (FILE *file, const char *str, va_list arg)
 CS version of vfprintf (stderr, str, .
csPtr< iConfigFilecsGetPlatformConfig (const char *key)
 Get a platform-specific per-user config object.
csString csGetPlatformConfigPath (const char *key, bool local=false)
 Get a platform-specific path to store per-user configuration data.
csTicks csGetTicks ()
 Get the current tick count.
csString csGetUsername ()
 Get the username of the account running the program.
bool csPlatformShutdown (iObjectRegistry *)
 Platform-specific shutdown.
bool csPlatformStartup (iObjectRegistry *)
 Platform-specific startup.
int csPrintf (const char *str,...)
 CS version of printf.
int csPrintfErr (const char *str,...)
 CS version of fprintf (stderr, str, .
int csPrintfErrV (const char *str, va_list arg)
 CS version of vfprintf (stderr, str, .
int csPrintfV (const char *str, va_list arg)
 CS version of vprintf.
void csSleep (int)
 This function will freeze your application for given number of 1/1000 seconds.


Detailed Description

Common system functions.

Definition in file sysfunc.h.


Function Documentation

bool csDefaultRunLoop iObjectRegistry  ) 
 

Implements a default run-loop for stand-alone applications.

This function implements a run-loop for stand-alone applications which do not provide their own run-loop. You only need to call this function if your application does not otherwise implement its own run-loop. For example, an existing Microsoft Windows-based application will already have a run-loop which processes the Windows event-queue, among other tasks. Such an application should not call this function, since doing so would interrupt the existing run-loop and prevent it from running. For each iteration of the run-loop, this function increments the Crystal Space virtual clock (if it is present in the shared-object registry at the time of the call to this function) and processes the Crystal Space event queue (which must be present in the shared-object registry at the time of the call to this function). This function only returns after a csevBroadcast message has been received in the Crystal Space event queue with command code cscmdQuit. The return value of this function indicates whether or not the run-loop was actually able to run. If there was a problem starting the run-loop, then `false' is returned, otherwise `true' is returned.

Referenced by csApplicationFramework::Run().

int csFPrintf FILE *  file,
const char *  str,
  ...
 

CS version of fprintf (file, str, .

..). It accepts UTF-8 strings and converts it, if required, to the platforms native codepage.

See also:
Notes about string formatting in CrystalSpace
Remarks:
Will not flush file.
See also:
Notes about string formatting in CrystalSpace

int csFPrintfV FILE *  file,
const char *  str,
va_list  arg
 

CS version of vfprintf (stderr, str, .

..). It accepts UTF-8 strings and converts it, if required, to the platforms native codepage.

See also:
Notes about string formatting in CrystalSpace
Remarks:
Will not flush file.
See also:
Notes about string formatting in CrystalSpace

csPtr<iConfigFile> csGetPlatformConfig const char *  key  ) 
 

Get a platform-specific per-user config object.

The data is stored in a platform-specific manner - e.g. in "Documents and Settings\Application Data" on Windows, or $HOME on Unix.

Parameters:
key Used to distinguish different stored configurations. Should be the application ID, e.g. "MyGames.ClickFrenzy2".
Returns:
A config 'file'. Might return 0 on some platforms or in case an error occured.

csString csGetPlatformConfigPath const char *  key,
bool  local = false
 

Get a platform-specific path to store per-user configuration data.

The path is in a platform-specific place - e.g. in "Documents and Settings\Application Data" on Windows, or $HOME on Unix.

Parameters:
key Used to distinguish different stored configurations. Should be the application ID, e.g. "MyGames.ClickFrenzy2".
local Some platforms also support "local" per-user configuration data, that is, when the per-user data is roamed over the network, such local data is still stored on the local machine(s). While unsuitable for for actual configuration data, it is useful e.g. in case the application does caching of some data on disk, and storing such data locally would reduce the network load in case the per-user data is roamed.
Returns:
A native path suitable to store per-user configuration data, in the form of e.g. "...\MyGames\ClickFrenzy2". The path could then be used as a directory name or a base for a file name.
Remarks:
The returned path may not exist. The caller has to ensure its existance before using it.

csTicks csGetTicks  ) 
 

Get the current tick count.

Warning! Do NOT use this function for controlling game logic speed. To do that you should use the virtual clock (iVirtualClock) which you can get from the object registry. By using the virtual clock it will be possible to control the speed of your game and also to pause it if needed.

csString csGetUsername  ) 
 

Get the username of the account running the program.

Returns the username of the owner of the process running the program. If the username can not be determined, then an empty string is returned.

bool csPlatformShutdown iObjectRegistry  ) 
 

Platform-specific shutdown.

Some platforms on which Crystal Space runs need to perform their own shutdown processing. Typically, this function is automatically called by the higher-level csInitializer::DestroyApplication(), however if you are performing application shutdown manually, you should call it yourself. Returns `true' if shutdown processing was successful, otherwise `false'.

bool csPlatformStartup iObjectRegistry  ) 
 

Platform-specific startup.

Some platforms on which Crystal Space runs need to perform their own startup processing. For instance, on some platforms, platform-specific "helper" objects may be placed in the shared-object registry for use by other platform-specific components. Typically, this function is automatically called by the higher-level csInitializer::CreateEnvironment(), however if you are performing application initialization manually, you should call it yourself. Returns `true' if startup initialization was successful, otherwise `false'.

int csPrintf const char *  str,
  ...
 

CS version of printf.

It accepts UTF-8 strings and converts it, if required, to the platforms native codepage.

See also:
Notes about string formatting in CrystalSpace

Referenced by csReporterHelper::ReportV().

int csPrintfErr const char *  str,
  ...
 

CS version of fprintf (stderr, str, .

..). It accepts UTF-8 strings and converts it, if required, to the platforms native codepage.

See also:
Notes about string formatting in CrystalSpace
Remarks:
Will flush stderr.
See also:
Notes about string formatting in CrystalSpace

Referenced by csBlockAllocator< csBSPTree >::Alloc(), and csBlockAllocator< csBSPTree >::DestroyObject().

int csPrintfErrV const char *  str,
va_list  arg
 

CS version of vfprintf (stderr, str, .

..). It accepts UTF-8 strings and converts it, if required, to the platforms native codepage.

See also:
Notes about string formatting in CrystalSpace
Remarks:
Will flush stderr.
See also:
Notes about string formatting in CrystalSpace

int csPrintfV const char *  str,
va_list  arg
 

CS version of vprintf.

It accepts UTF-8 strings and converts it, if required, to the platforms native codepage.

See also:
Notes about string formatting in CrystalSpace
See also:
Notes about string formatting in CrystalSpace

Referenced by csReporterHelper::ReportV().

void csSleep int   ) 
 

This function will freeze your application for given number of 1/1000 seconds.

The function is very inaccurate, so don't use it for accurate timing. It may be useful when the application is idle, to explicitly release CPU for other tasks in multi-tasking operating systems.


Generated for Crystal Space by doxygen 1.4.4