CrystalSpace

Public API Reference

csInitializer Class Reference
[Application Framework]

This class contains several static member functions that can help setup an application. More...

#include <cstool/initapp.h>

Inheritance diagram for csInitializer:

Inheritance graph
[legend]
List of all members.

Static Public Member Functions

static void CloseApplication (iObjectRegistry *)
 Send the csevSystemClose command to all loaded plugins.
static iCommandLineParserCreateCommandLineParser (iObjectRegistry *, int argc, char const *const argv[])
 Create the commandline parser.
static iConfigManagerCreateConfigManager (iObjectRegistry *)
 Create the config manager.
static iObjectRegistryCreateEnvironment (int argc, char const *const argv[])
 Create everything needed to get a CS application operational.
static iEventQueueCreateEventQueue (iObjectRegistry *)
 This essential function creates the event queue which is the main driving force between the event-driven CS model.
static bool CreateInputDrivers (iObjectRegistry *)
 This function will create the three common input drivers (csKeyboardDriver, csMouseDriver, and csJoystickDriver) and register them with the object registry.
static iObjectRegistryCreateObjectRegistry ()
 This function should be called second.
static iPluginManagerCreatePluginManager (iObjectRegistry *)
 You will almost certainly want to call this function.
static bool CreateStringSet (iObjectRegistry *)
 Create the global shared string set and register it with the registry.
static iVerbosityManagerCreateVerbosityManager (iObjectRegistry *)
 Create and, if needed, register the verbosity manager.
static iVirtualClockCreateVirtualClock (iObjectRegistry *)
 Create the virtual clock.
static void DestroyApplication (iObjectRegistry *)
 Destroy the application.
static const char * GetDefaultAppID ()
 The default application string name; computed from the executable name as passed in argv[0] to CreateEnvironment().
static bool InitializeSCF (int argc, char const *const argv[])
 This very important function initializes the SCF sub-system.
static bool OpenApplication (iObjectRegistry *)
 Send the csevSystemOpen command to all loaded plugins.
static bool RequestPlugins (iObjectRegistry *, csArray< csPluginRequest > const &)
 Request a few widely used standard plugins and also read the standard configuration file and command line for potential other plugins.
static bool RequestPlugins (iObjectRegistry *,...)
 Request a few widely used standard plugins and also read the standard configuration file and command line for potential other plugins.
static bool RequestPluginsV (iObjectRegistry *, va_list)
 This is just like RequestPlugins(.
static bool SetupConfigManager (iObjectRegistry *, const char *configName, const char *ApplicationID=0)
 Setup the config manager.
static bool SetupEventHandler (iObjectRegistry *, csEventHandlerFunc)
 Initialize an event handler function.
static bool SetupEventHandler (iObjectRegistry *, csEventHandlerFunc, const csEventID events[])
 Initialize an event handler function.
static bool SetupEventHandler (iObjectRegistry *, iEventHandler *, const csEventID[])
 Initialize an event handler for the application.
static iVFSSetupVFS (iObjectRegistry *objectReg, const char *pluginID="crystalspace.kernel.vfs")
 Find or load the VFS plugin, add it to the given object registry, and return it.

Detailed Description

This class contains several static member functions that can help setup an application.

It is possible to do all the setup on your own but using the functions below will help considerably.

Definition at line 164 of file initapp.h.


Member Function Documentation

static void csInitializer::CloseApplication ( iObjectRegistry  )  [static]

Send the csevSystemClose command to all loaded plugins.

static iCommandLineParser* csInitializer::CreateCommandLineParser ( iObjectRegistry ,
int  argc,
char const *const   argv[] 
) [static]

Create the commandline parser.

This function will register the created commandline parser with the object registry as the default parser (using 0 tag).

static iConfigManager* csInitializer::CreateConfigManager ( iObjectRegistry  )  [static]

Create the config manager.

This function will register the created config manager with the object registry as the default config manager (using 0 tag).

static iObjectRegistry* csInitializer::CreateEnvironment ( int  argc,
char const *const   argv[] 
) [static]

Create everything needed to get a CS application operational.

This function is completely equivalent to calling:

You may want to call all or some of those manually if you don't wish to use this function. It is suggested that CS_INITIALIZE_PLATFORM_APPLICATION, InitializeSCF(), and csPlatformStartup() are always invoked; the other calls can be replaced with manual creation of the respective objects. However, the order above should be retained when doing so.

Parameters:
argc argc argument from main().
argv argv argument from main().
Returns:
This function will return the pointer to the object registry where all the created objects will be registered.

static iEventQueue* csInitializer::CreateEventQueue ( iObjectRegistry  )  [static]

This essential function creates the event queue which is the main driving force between the event-driven CS model.

In addition this function will register the created event queue with the object registry as the default event queue (using 0 tag).

static bool csInitializer::CreateInputDrivers ( iObjectRegistry  )  [static]

This function will create the three common input drivers (csKeyboardDriver, csMouseDriver, and csJoystickDriver) and register them with the object registry.

Note that this function must be called after creating the config manager (CreateConfigManager()).

static iObjectRegistry* csInitializer::CreateObjectRegistry (  )  [static]

This function should be called second.

It will create the object registry and return a pointer to it. If there is a problem it will return 0.

static iPluginManager* csInitializer::CreatePluginManager ( iObjectRegistry  )  [static]

You will almost certainly want to call this function.

It will create the plugin manager which is essential for nearly everything. The created plugin manager will be registered with the object registry as the default plugin manager (using 0 tag).

static bool csInitializer::CreateStringSet ( iObjectRegistry  )  [static]

Create the global shared string set and register it with the registry.

This can be used if multiple, distinct modules want to share string IDs. The set can be requested with:

 csRef<iStringSet> strings = CS_QUERY_REGISTRY_TAG_INTERFACE (
   object_reg, "crystalspace.shared.stringset", iStringSet);

static iVerbosityManager* csInitializer::CreateVerbosityManager ( iObjectRegistry  )  [static]

Create and, if needed, register the verbosity manager.

It is used by a lot of plugins to control diagnostoc output while running.

static iVirtualClock* csInitializer::CreateVirtualClock ( iObjectRegistry  )  [static]

Create the virtual clock.

This clock is responsible for keeping track of virtual time in the game system. This function will register the created virtual clock with the object registry as the default virtual clock (using 0 tag).

static void csInitializer::DestroyApplication ( iObjectRegistry  )  [static]

Destroy the application.

Undo all of the initialization done by CreateEnvironment() or any of the other setup functions.

Remarks:
This will also unload all loaded plugins! So if you keep any references to plugins in the same scope as DestroyApplication (), clear those BEFORE calling DestroyApplication (). Example:
 class MyApp
 {
   csRef<iVFS> vfs;
  public:
   MyApp ();
   ~MyApp ()
   {
     csInitializer::DestroyApplication (...);
   }
 }
The above snippet will likely return in a crash at the end of the program - DestroyApplication () causes the unloading of all plugins, including VFS, however, the csRef<iVFS> is destroyed AFTER DestroyApplication () was called, so it'll try to DecRef() an object that has already been deleted. To fix the problem, either set 'vfs' to 0, or move DestroyApplication () into another scope (e.g. the main() of an application.)

static const char* csInitializer::GetDefaultAppID (  )  [static]

The default application string name; computed from the executable name as passed in argv[0] to CreateEnvironment().

If the latter was not called or argv[0] did not contain a sensible name, a default string is used.

Referenced by csApplicationFramework::GetApplicationName().

static bool csInitializer::InitializeSCF ( int  argc,
char const *const   argv[] 
) [static]

This very important function initializes the SCF sub-system.

Without this you can do almost nothing in CS.

static bool csInitializer::OpenApplication ( iObjectRegistry  )  [static]

Send the csevSystemOpen command to all loaded plugins.

This should be done after initializing them (Initialize()).

Referenced by csApplicationFramework::Open().

static bool csInitializer::RequestPlugins ( iObjectRegistry ,
csArray< csPluginRequest > const &   
) [static]

Request a few widely used standard plugins and also read the standard configuration file and command line for potential other plugins.

This routine must be called before Initialize().

Unlike the variable-argument RequestPlugins(...) method which expects you to know the list of requested plugins at compile-time, this overload allows you to construct an array of plugins at run-time. You do this by constructing a csArray<> of csPluginRequest records. For example:

WARNING csArray<> already knows its own size, so do not terminate the list with CS_REQUEST_END.

static bool csInitializer::RequestPlugins ( iObjectRegistry ,
  ... 
) [static]

Request a few widely used standard plugins and also read the standard configuration file and command line for potential other plugins.

This routine must be called before Initialize().

The variable arguments should contain four entries for every plugin you want to load: SCF class name, SCF interface name, inteface ID, and interface version. To make this easier it is recommended you use one of the CS_REQUEST_xxx macros above. WARNING Make sure to end the list with CS_REQUEST_END!

static bool csInitializer::RequestPluginsV ( iObjectRegistry ,
va_list   
) [static]

This is just like RequestPlugins(.

..), which accepts a variable list of arguments at compile-time, except that arguments are passed as a `va_list'.

static bool csInitializer::SetupConfigManager ( iObjectRegistry ,
const char *  configName,
const char *  ApplicationID = 0 
) [static]

Setup the config manager.

If you have no config file then you can still call this routine using a 0 parameter. If you don't call this then either RequestPlugins() or Initialize() will call this routine with 0 parameter. The 'ApplicationID' parameter is used to determine the correct user-specific domain; if 0, the return value of GetDefaultAppID() is used. It is possibly overriden by the application config file option "System.ApplicationID".

This method will load the VFS plugin if not already present in the given object registry.

Referenced by csApplicationFramework::SetupConfigManager().

static bool csInitializer::SetupEventHandler ( iObjectRegistry ,
csEventHandlerFunc   
) [static]

Initialize an event handler function.

This function will receive EVERY event that passes through the system. This is usually not what you want, since (1) it means you'll probably receive a lot of events you're not interested in, and (2) it's the most costly operation for the event subscription scheduler.

static bool csInitializer::SetupEventHandler ( iObjectRegistry ,
csEventHandlerFunc  ,
const csEventID  events[] 
) [static]

Initialize an event handler function.

This is an easier version of SetupEventHandler() that takes a function and will register an event handler to call that function for all stated events and their children, or (if the third argument is omitted) for all events.

static bool csInitializer::SetupEventHandler ( iObjectRegistry ,
iEventHandler ,
const   csEventID[] 
) [static]

Initialize an event handler for the application.

This is the most general routine. This event handler will receive all events that are sent through the event manager. Use this function to know about keyboard, mouse and other events. Note that you also have to use this function to be able to render something as rendering happens as a result of one event (csevProcess).

static iVFS* csInitializer::SetupVFS ( iObjectRegistry objectReg,
const char *  pluginID = "crystalspace.kernel.vfs" 
) [static]

Find or load the VFS plugin, add it to the given object registry, and return it.

An alternate plugin ID for VFS may be given as well. Use this method if you need to make changes to VFS, or use an alternate VFS plugin, before calling SetupConfigManager. Otherwise, SetupConfigManager will load the default VFS plugin automatically. objectReg can be the object registry object returned by CreateEnvironment, or one that you have manually set up with plugin and config manager objects.


The documentation for this class was generated from the following file:
Generated for Crystal Space 1.0.2 by doxygen 1.4.7