libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Platform Class Referenceabstract

Composition root for a platform. More...

#include <Platform.h>

Inheritance diagram for Platform:
[legend]

Public Member Functions

virtual void init (const PlatformConfig &config)=0
 Constructs and initializes all five drivers for this platform.
 
const PlatformConfig & getConfig () const
 The PlatformConfig this platform was init()'d with.
 
virtual void requestExit ()=0
 Tears down the platform (via shutdown()) and then performs whatever platform-appropriate action actually ends the app - return to loader/menu, power off, or just exit(), depending on how getSystemEvent() last reported and how the platform was reached.
 
virtual AudioDriver * getAudio ()=0
 
virtual VideoDriver * getVideo ()=0
 
virtual InputDriver * getInput ()=0
 
virtual FileSystemDriver * getFileSystem ()=0
 
virtual ThreadDriver * getThread ()=0
 
virtual Logger * getLogger ()=0
 May return nullptr on a Platform that hasn't finished init() yet - LogPrintf()/LOG_*() already guard against this, but code calling platform->getLogger() directly should too.
 
virtual SystemEvent getSystemEvent ()=0
 Current hardware/OS-level system event, if any.
 
virtual Status getStatus () const =0
 Current platform lifecycle state (Running, Paused, Exiting).
 
virtual void triggerExit ()=0
 Transitions platform state to move to Exiting.
 
bool shouldExit ()
 True once triggerExit() has been called, or the platform's own getSystemEvent() independently reports ShutdownRequested (eg.
 

Protected Member Functions

virtual void shutdown ()=0
 Shuts down and releases all five drivers.
 

Protected Attributes

PlatformConfig config {}
 Set by init() in every concrete Platform - store the passed-in config as the very first line of the override.
 

Detailed Description

Composition root for a platform.

Owns the five concrete drivers below and is the only place app code needs an #ifdef to pick a platform - everything else goes through the abstract driver interfaces.

Examples
demo.cpp.

Definition at line 65 of file Platform.h.

Member Function Documentation

◆ getAudio()

virtual AudioDriver * Platform::getAudio ( )
pure virtual
Returns
the audio driver, valid once init() has run

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ getConfig()

const PlatformConfig & Platform::getConfig ( ) const
inline

The PlatformConfig this platform was init()'d with.

Definition at line 74 of file Platform.h.

◆ getFileSystem()

virtual FileSystemDriver * Platform::getFileSystem ( )
pure virtual
Returns
the storage driver, valid once init() has run

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ getInput()

virtual InputDriver * Platform::getInput ( )
pure virtual
Returns
the input driver, valid once init() has run

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ getLogger()

virtual Logger * Platform::getLogger ( )
pure virtual

May return nullptr on a Platform that hasn't finished init() yet - LogPrintf()/LOG_*() already guard against this, but code calling platform->getLogger() directly should too.

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ getStatus()

virtual Status Platform::getStatus ( ) const
pure virtual

Current platform lifecycle state (Running, Paused, Exiting).

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ getSystemEvent()

virtual SystemEvent Platform::getSystemEvent ( )
pure virtual

Current hardware/OS-level system event, if any.

A single query rather than independent shutdown/reset flags.

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ getThread()

virtual ThreadDriver * Platform::getThread ( )
pure virtual
Returns
the thread driver, valid once init() has run

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ getVideo()

virtual VideoDriver * Platform::getVideo ( )
pure virtual
Returns
the video driver, valid once init() has run

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ init()

virtual void Platform::init ( const PlatformConfig & config)
pure virtual

Constructs and initializes all five drivers for this platform.

Parameters
configGUI canvas size and asset scale for this platform

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ requestExit()

virtual void Platform::requestExit ( )
pure virtual

Tears down the platform (via shutdown()) and then performs whatever platform-appropriate action actually ends the app - return to loader/menu, power off, or just exit(), depending on how getSystemEvent() last reported and how the platform was reached.

It does not return.

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ shouldExit()

bool Platform::shouldExit ( )
inline

True once triggerExit() has been called, or the platform's own getSystemEvent() independently reports ShutdownRequested (eg.

a hardware power button). Not every platform folds Status::Exiting into its getSystemEvent() report - GameCube has no hardware event source and always reports None, relying entirely on triggerExit() - so callers wanting to leave promptly on either signal should check this rather than either alone.

Definition at line 112 of file Platform.h.

◆ shutdown()

virtual void Platform::shutdown ( )
protectedpure virtual

Shuts down and releases all five drivers.

Any background Thread that might still call into a driver must be stopped and joined (eg. via Thread::JoinAll()) before calling this, since the drivers it deletes may be in active use.

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

◆ triggerExit()

virtual void Platform::triggerExit ( )
pure virtual

Transitions platform state to move to Exiting.

Implemented in GameCubePlatform, WiiPlatform, and WutPlatform.

Member Data Documentation

◆ config

PlatformConfig Platform::config {}
protected

Set by init() in every concrete Platform - store the passed-in config as the very first line of the override.

Definition at line 117 of file Platform.h.


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