The Battle for Wesnoth  1.19.7+dev
Public Member Functions | Private Member Functions | Private Attributes | List of all members
name_generator_factory Class Reference

#include <name_generator_factory.hpp>

Public Member Functions

 name_generator_factory (const config &config, std::vector< std::string > ids)
 Creates a new name generator factory. More...
 
std::shared_ptr< name_generatorget_name_generator ()
 Gets the default name generator. More...
 
std::shared_ptr< name_generatorget_name_generator (const std::string &name)
 Gets a specific name generator or the default name generator, if the specific name generator is not found. More...
 

Private Member Functions

void add_name_generator_from_config (const config &config, const std::string &id, const std::string &prefix)
 Determines a name generator from WML data. More...
 

Private Attributes

std::map< std::string, std::shared_ptr< name_generator > > name_generators_
 

Detailed Description

Definition at line 23 of file name_generator_factory.hpp.

Constructor & Destructor Documentation

◆ name_generator_factory()

name_generator_factory::name_generator_factory ( const config config,
std::vector< std::string >  ids 
)

Creates a new name generator factory.

Parameters
configthe WML data to be parsed for name generators
idsa list of generator ids, e.g. genders or terrain types

Definition at line 29 of file name_generator_factory.cpp.

References add_name_generator_from_config().

Member Function Documentation

◆ add_name_generator_from_config()

void name_generator_factory::add_name_generator_from_config ( const config config,
const std::string &  id,
const std::string &  prefix 
)
private

Determines a name generator from WML data.

Tries first to load a context-free generator, then falls back to Markov.

Parameters
configthe WML data to be parsed for name generators
idthe generator id to use
prefixthe prefix to look for

Definition at line 38 of file name_generator_factory.cpp.

References config_attribute_value::blank(), ERR_WML, config::has_attribute(), id, lg::log_to_chat(), name_generators_, utils::split(), and name_generator_invalid_exception::what().

Referenced by name_generator_factory().

◆ get_name_generator() [1/2]

std::shared_ptr< name_generator > name_generator_factory::get_name_generator ( )

Gets the default name generator.

Returns
the default name generator

Definition at line 62 of file name_generator_factory.cpp.

References name_generators_.

Referenced by get_name_generator(), and unit_race::unit_race().

◆ get_name_generator() [2/2]

std::shared_ptr< name_generator > name_generator_factory::get_name_generator ( const std::string &  name)

Gets a specific name generator or the default name generator, if the specific name generator is not found.

Parameters
namegenerator id, e.g. a gender or a terrain type
Returns
a name generator

Definition at line 72 of file name_generator_factory.cpp.

References get_name_generator(), and name_generators_.

Member Data Documentation

◆ name_generators_

std::map<std::string, std::shared_ptr<name_generator> > name_generator_factory::name_generators_
private

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