stmm-games-doc  0.32.0
Classes | Public Member Functions | List of all members
stmg::XmlGameLoader Class Reference
Inheritance diagram for stmg::XmlGameLoader:
Inheritance graph
[legend]

Classes

struct  Init
 

Public Member Functions

 XmlGameLoader (Init &&oInit)
 Constructor. More...
 
const std::vector< std::string > & getGameNames () noexcept override
 The game names supported by this loader. More...
 
std::vector< std::string > getGameNames (const AppPreferences &oAppPreferences) noexcept override
 The game names supported by this loader that satisfy the preferences. More...
 
const GameInfogetGameInfo (const std::string &sGameName) noexcept override
 The game information by name. More...
 
const std::string & getDefaultGameName () const noexcept override
 The default game name. More...
 
std::pair< shared_ptr< Game >, bool > getNewGame (const std::string &sGameName, GameOwner &oGameOwner, const shared_ptr< AppPreferences > &refAppPreferences, const Named &oNamed, const shared_ptr< Highscore > &refHighscore) noexcept override
 Get a new game. More...
 
- Public Member Functions inherited from stmg::GameLoader
virtual ~GameLoader () noexcept=default
 

Constructor & Destructor Documentation

◆ XmlGameLoader()

stmg::XmlGameLoader::XmlGameLoader ( Init &&  oInit)
explicit

Constructor.

Parameters
oInitInizialization data..

Member Function Documentation

◆ getDefaultGameName()

const std::string& stmg::XmlGameLoader::getDefaultGameName ( ) const
overridevirtualnoexcept

The default game name.

Returns
The default game name. Can be empty.

Implements stmg::GameLoader.

◆ getGameInfo()

const GameInfo& stmg::XmlGameLoader::getGameInfo ( const std::string &  sGameName)
overridevirtualnoexcept

The game information by name.

Parameters
sGameNameThe name. The game must exist. Cannot be empty.
Returns
The game information.

Implements stmg::GameLoader.

◆ getGameNames() [1/2]

const std::vector<std::string>& stmg::XmlGameLoader::getGameNames ( )
overridevirtualnoexcept

The game names supported by this loader.

Returns
The (unique) non-empty names of the games.

Implements stmg::GameLoader.

◆ getGameNames() [2/2]

std::vector<std::string> stmg::XmlGameLoader::getGameNames ( const AppPreferences oAppPreferences)
overridevirtualnoexcept

The game names supported by this loader that satisfy the preferences.

Parameters
oAppPreferencesThe preferences.
Returns
The (unique) non-empty names of the games.

Implements stmg::GameLoader.

◆ getNewGame()

std::pair<shared_ptr<Game>, bool> stmg::XmlGameLoader::getNewGame ( const std::string &  sGameName,
GameOwner oGameOwner,
const shared_ptr< AppPreferences > &  refAppPreferences,
const Named oThemeNamed,
const shared_ptr< Highscore > &  refHighscore 
)
overridevirtualnoexcept

Get a new game.

If null is returned and error string in GameInfo is empty, it means the game is not compatible with the given preferences.

If parameter refHighscore is not null, it must have been created by the GameInfo::m_refHighscoresDefinition of the game.

Parameters
sGameNameThe name of the game (which must exist) or empty if loader should choose.
oGameOwnerThe owner of the game.
refAppPreferencesThe preferences. Cannot be null.
oThemeNamedThe theme named from which game makes a copy.
refHighscoreThe highscores for the game (and current preferences). Can be null,
Returns
The game and whether the highscores were ignored or null if could not load.

Implements stmg::GameLoader.