September 4, 2010
Purveyor of Intelligent Independent Games. Est 2009.
   
 
This is the documentation for the Pixie Game Engine.

Platform Class Reference

Singleton class for handling platform abstraction systems. More...

List of all members.


Detailed Description

Singleton class for handling platform abstraction systems.

Author:
Mattias Gustavsson
The Platform system consists of several different systems, which defines the interface to different parts of the OS or hardware. When the application starts, you must define which implementation to use for each of the platform systems (interfaces) that you want to utilize in your application. This is done by creating an instance of the platform specific implementation, and passing it to the Platform singleton, from which it can be retrieved whevenever needed.

And any system can later be accessed by calling, for example: Platform::GetPlatform_OS()

The platform system has been designed to be easy to port, rather than to be easy to use, so it only provides a thin abstraction layer. More user-friendly functionality is built on top of this in the Pixie game engine, and you rarely, if ever, need to use the Platform systemes directly (thouhgh the Pixie engine makes frequent use of it).

There's a NULL platform implementation provided, wich implements empty functions for all the systems, which can be useful when porting or debugging. The NULL implementations will return valid objects and have all functions callable, but they will not perform any functionality and will mostly return 0 values.

Definition at line 61 of file Platform.h.


Static Public Member Functions

static void SetPlatform_OS (Platform_OS *instance)
static void SetPlatform_Time (Platform_Time *instance)
static void SetPlatform_Sound (Platform_Sound *instance)
static void SetPlatform_Input (Platform_Input *instance)
static void SetPlatform_FileSystem (Platform_FileSystem *instance)
static void SetPlatform_Screen (Platform_Screen *instance)
static Platform_OSGetPlatform_OS ()
static Platform_TimeGetPlatform_Time ()
static Platform_SoundGetPlatform_Sound ()
static Platform_InputGetPlatform_Input ()
static Platform_FileSystemGetPlatform_FileSystem ()
static Platform_ScreenGetPlatform_Screen ()
static void RegisterEventListener (PlatformEventListener *listener)
static void UnregisterEventListener (PlatformEventListener *listener)
static void SendEvent_OsYield ()
static void SendEvent_CustomEvent (const char *eventId, void *userData=0)

Member Function Documentation

void Platform::SetPlatform_OS ( Platform_OS instance  )  [static]

Specifies the Platform_OS instance to use. Ownership of the pointer passed in will be owned and managed by the Platform system, which will also delete the instance on termination, by calling delete, so make sure it is allocated on the heap using the new keyword - but don't delete it yourself. If an instance have already been specified through a prior call to this method, this method will have no effect, and the previous instance will still be the one used, and the pointer passed in will just be immediately deleted.

Parameters:
instance Pointer to the instance

Definition at line 142 of file Platform.cpp.

void Platform::SetPlatform_Time ( Platform_Time instance  )  [static]

Specifies the Platform_Time instance to use. Ownership of the pointer passed in will be owned and managed by the Platform system, which will also delete the instance on termination, by calling delete, so make sure it is allocated on the heap using the new keyword - but don't delete it yourself. If an instance have already been specified through a prior call to this method, this method will have no effect, and the previous instance will still be the one used, and the pointer passed in will just be immediately deleted.

Parameters:
instance Pointer to the instance

Definition at line 165 of file Platform.cpp.

void Platform::SetPlatform_Sound ( Platform_Sound instance  )  [static]

Specifies the Platform_Sound instance to use. Ownership of the pointer passed in will be owned and managed by the Platform system, which will also delete the instance on termination, by calling delete, so make sure it is allocated on the heap using the new keyword - but don't delete it yourself. If an instance have already been specified through a prior call to this method, this method will have no effect, and the previous instance will still be the one used, and the pointer passed in will just be immediately deleted.

Parameters:
instance Pointer to the instance

Definition at line 188 of file Platform.cpp.

void Platform::SetPlatform_Input ( Platform_Input instance  )  [static]

Specifies the Platform_Input instance to use. Ownership of the pointer passed in will be owned and managed by the Platform system, which will also delete the instance on termination, by calling delete, so make sure it is allocated on the heap using the new keyword - but don't delete it yourself. If an instance have already been specified through a prior call to this method, this method will have no effect, and the previous instance will still be the one used, and the pointer passed in will just be immediately deleted.

Parameters:
instance Pointer to the instance

Definition at line 211 of file Platform.cpp.

void Platform::SetPlatform_FileSystem ( Platform_FileSystem instance  )  [static]

Specifies the Platform_FileSystem instance to use. Ownership of the pointer passed in will be owned and managed by the Platform system, which will also delete the instance on termination, by calling delete, so make sure it is allocated on the heap using the new keyword - but don't delete it yourself. If an instance have already been specified through a prior call to this method, this method will have no effect, and the previous instance will still be the one used, and the pointer passed in will just be immediately deleted.

Parameters:
instance Pointer to the instance

Definition at line 234 of file Platform.cpp.

void Platform::SetPlatform_Screen ( Platform_Screen instance  )  [static]

Specifies the Platform_Screen instance to use. Ownership of the pointer passed in will be owned and managed by the Platform system, which will also delete the instance on termination, by calling delete, so make sure it is allocated on the heap using the new keyword - but don't delete it yourself. If an instance have already been specified through a prior call to this method, this method will have no effect, and the previous instance will still be the one used, and the pointer passed in will just be immediately deleted.

Parameters:
instance Pointer to the instance

Definition at line 257 of file Platform.cpp.

Platform_OS * Platform::GetPlatform_OS (  )  [static]

Retrieves the pointer to the global instance of the Platform_OS system. The value returned might be 0 if no instance have been specified through a call to SetPlatform_OS, and the caller should test the return value to make sure it is a valid pointer.

Returns:
A pointer to the Platform_OS instance, or 0 if it hasn't been set

Definition at line 134 of file Platform.cpp.

Platform_Time * Platform::GetPlatform_Time (  )  [static]

Retrieves the pointer to the global instance of the Platform_Time system. The value returned might be 0 if no instance have been specified through a call to SetPlatform_Time, and the caller should test the return value to make sure it is a valid pointer.

Returns:
A pointer to the Platform_Time instance, or 0 if it hasn't been set

Definition at line 157 of file Platform.cpp.

Platform_Sound * Platform::GetPlatform_Sound (  )  [static]

Retrieves the pointer to the global instance of the Platform_Sound system. The value returned might be 0 if no instance have been specified through a call to SetPlatform_Sound, and the caller should test the return value to make sure it is a valid pointer.

Returns:
A pointer to the Platform_Sound instance, or 0 if it hasn't been set

Definition at line 180 of file Platform.cpp.

Platform_Input * Platform::GetPlatform_Input (  )  [static]

Retrieves the pointer to the global instance of the Platform_Input system. The value returned might be 0 if no instance have been specified through a call to SetPlatform_Input, and the caller should test the return value to make sure it is a valid pointer.

Returns:
A pointer to the Platform_Input instance, or 0 if it hasn't been set

Definition at line 203 of file Platform.cpp.

Platform_FileSystem * Platform::GetPlatform_FileSystem (  )  [static]

Retrieves the pointer to the global instance of the Platform_FileSystem system. The value returned might be 0 if no instance have been specified through a call to SetPlatform_FileSystem, and the caller should test the return value to make sure it is a valid pointer.

Returns:
A pointer to the Platform_FileSystem instance, or 0 if it hasn't been set

Definition at line 226 of file Platform.cpp.

Platform_Screen * Platform::GetPlatform_Screen (  )  [static]

Retrieves the pointer to the global instance of the Platform_Screen system. The value returned might be 0 if no instance have been specified through a call to SetPlatform_Screen, and the caller should test the return value to make sure it is a valid pointer.

Returns:
A pointer to the Platform_Screen instance, or 0 if it hasn't been set

Definition at line 249 of file Platform.cpp.

void Platform::RegisterEventListener ( PlatformEventListener listener  )  [static]

To make it easier for the platform specific implementations to communicate without specific knowledge of each other, a simple event system is provided. By deriving a platform system from PlatformEventListener, and register it for events using this methods, the system will be notified every time another platform system sends a platform event.

Parameters:
listener Object that is to receive platform events

Definition at line 78 of file Platform.cpp.

void Platform::UnregisterEventListener ( PlatformEventListener listener  )  [static]

Unregisters an event listener that was registered through a call to RegisterEventListener. You can call this method to stop receiving events, but you MUST call it when before the registered object is destroyed (typically from its destructor).

Parameters:
listener Object that should stop receiving platform events

Definition at line 91 of file Platform.cpp.

void Platform::SendEvent_OsYield (  )  [static]

Send the "OsYield" platform event to all registered event listeners. This is a special event, which is sent by Platform_OS every time the OsYield method is called, and can be used for systems which needs to do per-frame updates.

Definition at line 109 of file Platform.cpp.

void Platform::SendEvent_CustomEvent ( const char *  eventId,
void *  userData = 0 
) [static]

Sends a custom event to all registered event listeners. A custom event can be anything - it is defined by an id string, for what type of event it is, and an optional pointer to user-defined data.

Parameters:
eventId The id defining the type of event
userData Pointer to optional user data for this event

Definition at line 121 of file Platform.cpp.

 
   

What's This?

    We offer you the very best strategy, roleplaying and sim games.
    Read More

Are you a Game Developer?
Click Here

Developers

    Are you a game developer making strategy, roleplaying or sim games? We have some great resources for you!
    Read More

Gamers

    Are you a fan of strategy, roleplaying or simulation games? Let us know what you think!
    Read More