Platform Class ReferenceSingleton class for handling platform abstraction systems. More...
Detailed DescriptionSingleton class for handling platform abstraction systems.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.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Platform_Win32_OS* os=new Platform_Win32_OS(hInstance,lpCmdLine); Platform::SetPlatform_OS(os); Platform::SetPlatform_Time(new Platform_Win32_Time()); Platform::SetPlatform_Sound(new Platform_Win32_Sound(os)); Platform::SetPlatform_Input(new Platform_Win32_Input(os)); Platform::SetPlatform_Screen(new Platform_Win32_Screen(os)); Platform::SetPlatform_FileSystem(new Platform_Win32_FileSystem()); ... } 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.
Member Function Documentation
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.
Definition at line 142 of file Platform.cpp.
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.
Definition at line 165 of file Platform.cpp.
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.
Definition at line 188 of file Platform.cpp.
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.
Definition at line 211 of file Platform.cpp.
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.
Definition at line 234 of file Platform.cpp.
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.
Definition at line 257 of file Platform.cpp.
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.
Definition at line 134 of file Platform.cpp.
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.
Definition at line 157 of file Platform.cpp.
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.
Definition at line 180 of file Platform.cpp.
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.
Definition at line 203 of file Platform.cpp.
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.
Definition at line 226 of file Platform.cpp.
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.
Definition at line 249 of file Platform.cpp.
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.
Definition at line 78 of file Platform.cpp.
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).
Definition at line 91 of file Platform.cpp.
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.
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.
Definition at line 121 of file Platform.cpp.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

