World Builder  1.1.0-pre
A geodynamic initial conditions generator
WorldBuilder::Parameters Class Reference

#include <parameters.h>

Collaboration diagram for WorldBuilder::Parameters:

Public Member Functions

 Parameters (World &world)
 
 ~Parameters ()
 
void initialize (std::string &filename, bool has_output_dir=false, const std::string &output_dir="")
 
template<class T >
get (const std::string &name)
 
template<class T >
std::vector< T > get_vector (const std::string &name)
 
std::vector< std::vector< double > > get_vector_or_double (const std::string &name)
 
std::pair< std::vector< double >, std::vector< double > > get (const std::string &name, const std::vector< Point< 2 > > &addition_points={})
 
std::pair< std::vector< double >, std::vector< double > > get_value_at_array (const std::string &name)
 
template<class T , class A , class B , class C , class D >
std::vector< T > get_vector (const std::string &name, std::vector< std::shared_ptr< A > > &, std::vector< std::shared_ptr< B > > &, std::vector< std::shared_ptr< C > > &, std::vector< std::shared_ptr< D > > &)
 
template<class T >
std::unique_ptr< T > get_unique_pointer (const std::string &name)
 
template<class T >
bool get_unique_pointers (const std::string &name, std::vector< std::unique_ptr< T > > &vector)
 
template<class T >
bool get_shared_pointers (const std::string &name, std::vector< std::shared_ptr< T > > &)
 
bool check_entry (const std::string &name) const
 
void declare_entry (const std::string &name, const Types::Interface &type, const std::string &documentation)
 
void enter_subsection (const std::string &name)
 
void leave_subsection ()
 
void declare_model_entries (const std::string &model_group_name, const std::string &parent_name, const std::map< std::string, void(*)(Parameters &, const std::string &)> &declare_map, const std::vector< std::string > &required_entries={}, const std::vector< std::tuple< std::string, const WorldBuilder::Types::Interface &, std::string > > &extra_declarations={})
 
std::string get_full_json_path (size_t max_size=std::numeric_limits< size_t >::max()) const
 
std::string get_full_json_schema_path () const
 
template<>
std::string get (const std::string &name)
 
template<>
double get (const std::string &name)
 
template<>
size_t get (const std::string &name)
 
template<>
unsigned int get (const std::string &name)
 
template<>
int get (const std::string &name)
 
template<>
bool get (const std::string &name)
 
template<>
Point< 2 > get (const std::string &name)
 
template<>
std::vector< bool > get_vector (const std::string &name)
 
template<>
std::vector< Point< 2 > > get_vector (const std::string &name)
 
template<>
std::vector< std::array< double, 3 > > get_vector (const std::string &name)
 
template<>
std::vector< std::array< std::array< double, 3 >, 3 > > get_vector (const std::string &name)
 
template<>
std::vector< std::vector< Point< 2 > > > get_vector (const std::string &name)
 
template<>
std::vector< Objects::Segment< Features::SubductingPlateModels::Temperature::Interface, Features::SubductingPlateModels::Composition::Interface, Features::SubductingPlateModels::Grains::Interface, Features::SubductingPlateModels::Velocity::Interface > > get_vector (const std::string &name, std::vector< std::shared_ptr< Features::SubductingPlateModels::Temperature::Interface > > &default_temperature_models, std::vector< std::shared_ptr< Features::SubductingPlateModels::Composition::Interface > > &default_composition_models, std::vector< std::shared_ptr< Features::SubductingPlateModels::Grains::Interface > > &default_grains_models, std::vector< std::shared_ptr< Features::SubductingPlateModels::Velocity::Interface > > &default_velocity_models)
 
template<>
std::vector< Objects::Segment< Features::FaultModels::Temperature::Interface, Features::FaultModels::Composition::Interface, Features::FaultModels::Grains::Interface, Features::FaultModels::Velocity::Interface > > get_vector (const std::string &name, std::vector< std::shared_ptr< Features::FaultModels::Temperature::Interface > > &default_temperature_models, std::vector< std::shared_ptr< Features::FaultModels::Composition::Interface > > &default_composition_models, std::vector< std::shared_ptr< Features::FaultModels::Grains::Interface > > &default_grains_models, std::vector< std::shared_ptr< Features::FaultModels::Velocity::Interface > > &default_velocity_models)
 
template<>
std::vector< double > get_vector (const std::string &name)
 
template<>
std::vector< size_t > get_vector (const std::string &name)
 
template<>
std::vector< unsigned int > get_vector (const std::string &name)
 
template<>
bool get_unique_pointers (const std::string &name, std::vector< std::unique_ptr< Features::SubductingPlate > > &vector)
 
template<>
bool get_unique_pointers (const std::string &name, std::vector< std::unique_ptr< Features::Fault > > &vector)
 

Public Attributes

Worldworld
 
const std::string path_separator = "."
 
std::vector< std::string > path
 
rapidjson::Document declarations
 
rapidjson::Document parameters
 
std::vector< std::unique_ptr< WorldBuilder::Features::Interface > > features
 
std::unique_ptr< WorldBuilder::CoordinateSystems::Interfacecoordinate_system
 
std::unique_ptr< WorldBuilder::GravityModel::Interfacegravity_model
 

Private Member Functions

std::string get_relative_path () const
 
std::string get_relative_path_without_arrays () const
 

Private Attributes

size_t path_level
 

Detailed Description

A class to hold all the parameters needed by the world builder. Internally it holds all values in the form of vectors of class Types. Values can be entered in two ways into this class. The first way is through the load_entry function which load the value from the provided world builder file. The second way is through the set_entry function, through which values can be directly entered into the parameter class. Values can be retrieved through the get functions which take the name of the value with which it was set. It is also required for bot loading, setting and getting values to do it in the correct subsection. Subsections can be entered with the enter_subsection function and left with the leave_subsection function. The current path can be retrieved through the function get_current_path() and get_current_path_without_arrays().

Definition at line 78 of file parameters.h.

Constructor & Destructor Documentation

◆ Parameters()

WorldBuilder::Parameters::Parameters ( World world)

Constructor

Parameters
worldA reference to the World class

Definition at line 79 of file parameters.cc.

Here is the call graph for this function:

◆ ~Parameters()

WorldBuilder::Parameters::~Parameters ( )
default

Destructor

Here is the caller graph for this function:

Member Function Documentation

◆ check_entry()

bool WorldBuilder::Parameters::check_entry ( const std::string &  name) const

Checks for the existence of an entry in the parameter file. Return true when an entry is specified and false when it is not. This is independent of whether an entry has been declared or not. The main intended usage is to check whether the user has provided the specified entry in the user supplied parameters file, since the get functions may use default values.

Parameters
nameThe name of the entry to be checked.

Definition at line 205 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ declare_entry()

void WorldBuilder::Parameters::declare_entry ( const std::string &  name,
const Types::Interface type,
const std::string &  documentation 
)

Declares the existence an entry in the parameters class. Default values are supplied by the type.

Parameters
nameThe name of the entry to be declared
typeThe type of entry (e.g. Double, Array, etc.)
documentationA string containing information about this parameter.

Definition at line 197 of file parameters.cc.

Here is the call graph for this function:

◆ declare_model_entries()

void WorldBuilder::Parameters::declare_model_entries ( const std::string &  model_group_name,
const std::string &  parent_name,
const std::map< std::string, void(*)(Parameters &, const std::string &)> &  declare_map,
const std::vector< std::string > &  required_entries = {},
const std::vector< std::tuple< std::string, const WorldBuilder::Types::Interface &, std::string > > &  extra_declarations = {} 
)

A utilities function for declaring plugin model entries. This always contains a model declaration entry with the plugin name.

Parameters
model_group_nameThe name of the model group which is declared.
parent_nameThe name of the parent declaration group.
declaration_mapA map containing plugin names and plugin declaration functions
required_entriesA vector containing what entries should be required from the user. Default value is empty.
extra_declarationsA vector containing extra declarations common to all plugins in this group. Default value is empty.

Definition at line 1886 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enter_subsection()

void WorldBuilder::Parameters::enter_subsection ( const std::string &  name)

This function is used to enter a subsection. It appends to the path variable. This action is revesed by the leave subsection function.

Parameters
nameThe name of the subsection to be entered.
See also
path
leave_subsection()

Definition at line 1871 of file parameters.cc.

Here is the caller graph for this function:

◆ get() [1/9]

template<class T >
T WorldBuilder::Parameters::get ( const std::string &  name)

A generic get function to retrieve setting from the parameter file. Note that this is dependent on the current path/subsection which you are in.

Parameters
nameThe name of the entry to retrieved
See also
path
enter_subsection()
leave_subsection()

◆ get() [2/9]

std::pair< std::vector< double >, std::vector< double > > WorldBuilder::Parameters::get ( const std::string &  name,
const std::vector< Point< 2 > > &  addition_points = {} 
)

A specialized version of get which can return a value at points type.

Parameters
nameThe name of the entry to retrieved
nameadditional points to be added to the list at either the default value or at the value of a single value array in the list

Definition at line 512 of file parameters.cc.

Here is the call graph for this function:

◆ get() [3/9]

template<>
std::string WorldBuilder::Parameters::get ( const std::string &  name)

Definition at line 213 of file parameters.cc.

Here is the call graph for this function:

◆ get() [4/9]

template<>
double WorldBuilder::Parameters::get ( const std::string &  name)

Definition at line 247 of file parameters.cc.

Here is the call graph for this function:

◆ get() [5/9]

template<>
size_t WorldBuilder::Parameters::get ( const std::string &  name)

Definition at line 290 of file parameters.cc.

Here is the call graph for this function:

◆ get() [6/9]

template<>
unsigned int WorldBuilder::Parameters::get ( const std::string &  name)

Definition at line 324 of file parameters.cc.

Here is the call graph for this function:

◆ get() [7/9]

template<>
int WorldBuilder::Parameters::get ( const std::string &  name)

Definition at line 358 of file parameters.cc.

Here is the call graph for this function:

◆ get() [8/9]

template<>
bool WorldBuilder::Parameters::get ( const std::string &  name)

Definition at line 392 of file parameters.cc.

Here is the call graph for this function:

◆ get() [9/9]

template<>
Point<2> WorldBuilder::Parameters::get ( const std::string &  name)

Definition at line 427 of file parameters.cc.

Here is the call graph for this function:

◆ get_full_json_path()

std::string WorldBuilder::Parameters::get_full_json_path ( size_t  max_size = std::numeric_limits<size_t>::max()) const

This function return the current path as stored in the path variable as a string in json pointer format.

Returns
std::string

Definition at line 1933 of file parameters.cc.

Here is the caller graph for this function:

◆ get_full_json_schema_path()

std::string WorldBuilder::Parameters::get_full_json_schema_path ( ) const

todo: Warning: do not use before declarations is filled. This function return the current path as stored in the path variable as a string in json pointer format.

Returns
std::string

Definition at line 1944 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_relative_path()

std::string WorldBuilder::Parameters::get_relative_path ( ) const
private

A function which returns the relative path, which is the full path minus the path_level top entries..

See also
get_current_path()

◆ get_relative_path_without_arrays()

std::string WorldBuilder::Parameters::get_relative_path_without_arrays ( ) const
private

A function which returns the relative path, which is the full path minus the path_level top entries., without names for the arrays.

See also
get_current_path_without_arrays()

◆ get_shared_pointers()

template<class T >
bool WorldBuilder::Parameters::get_shared_pointers ( const std::string &  name,
std::vector< std::shared_ptr< T > > &  vector 
)

A specialized version of get which can return shared pointers as an argument and returns a bool to indicate whether it was successful or not. Note that this function will erase all information in the vector.

Parameters
nameThe name of the entry to retrieved
vectorA vector of shared pointers.

Definition at line 1845 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unique_pointer()

template<class T >
std::unique_ptr< T > WorldBuilder::Parameters::get_unique_pointer ( const std::string &  name)

A specialized version of get which can return unique pointers.

Parameters
nameThe name of the entry to retrieved

Definition at line 1738 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unique_pointers() [1/3]

template<class T >
bool WorldBuilder::Parameters::get_unique_pointers ( const std::string &  name,
std::vector< std::unique_ptr< T > > &  vector 
)

A specialized version of get which can return unique pointers as an argument and returns a bool to indicate whether it was successful or not. Note that this function will erase all information in the vector.

Parameters
nameThe name of the entry to retrieved
vectorA vector of unique pointers.

Definition at line 1770 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unique_pointers() [2/3]

template<>
bool WorldBuilder::Parameters::get_unique_pointers ( const std::string &  name,
std::vector< std::unique_ptr< Features::SubductingPlate > > &  vector 
)

Definition at line 1797 of file parameters.cc.

Here is the call graph for this function:

◆ get_unique_pointers() [3/3]

template<>
bool WorldBuilder::Parameters::get_unique_pointers ( const std::string &  name,
std::vector< std::unique_ptr< Features::Fault > > &  vector 
)

Definition at line 1820 of file parameters.cc.

Here is the call graph for this function:

◆ get_value_at_array()

std::pair< std::vector< double >, std::vector< double > > WorldBuilder::Parameters::get_value_at_array ( const std::string &  name)

A specialized version of get which can return a values at times type.

Parameters
nameThe name of the entry to retrieved

Definition at line 719 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_vector() [1/12]

template<class T >
std::vector<T> WorldBuilder::Parameters::get_vector ( const std::string &  name)

A specialized version of get which can return vectors/arrays.

Parameters
nameThe name of the entry to retrieved
Here is the caller graph for this function:

◆ get_vector() [2/12]

template<class T , class A , class B , class C , class D >
std::vector<T> WorldBuilder::Parameters::get_vector ( const std::string &  name,
std::vector< std::shared_ptr< A > > &  ,
std::vector< std::shared_ptr< B > > &  ,
std::vector< std::shared_ptr< C > > &  ,
std::vector< std::shared_ptr< D > > &   
)

A specialized version of get which can return vectors/arrays. This version is designed for the plugin system.

Parameters
nameThe name of the entry to retrieved

◆ get_vector() [3/12]

template<>
std::vector<bool> WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 475 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [4/12]

template<>
std::vector<Point<2> > WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 854 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [5/12]

template<>
std::vector<std::array<double,3> > WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 888 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [6/12]

template<>
std::vector<std::array<std::array<double,3>,3> > WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 1033 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [7/12]

template<>
std::vector<std::vector<Point<2> > > WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 1087 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [8/12]

template<>
std::vector<Objects::Segment<Features::SubductingPlateModels::Temperature::Interface, Features::SubductingPlateModels::Composition::Interface, Features::SubductingPlateModels::Grains::Interface, Features::SubductingPlateModels::Velocity::Interface> > WorldBuilder::Parameters::get_vector ( const std::string &  name,
std::vector< std::shared_ptr< Features::SubductingPlateModels::Temperature::Interface > > &  default_temperature_models,
std::vector< std::shared_ptr< Features::SubductingPlateModels::Composition::Interface > > &  default_composition_models,
std::vector< std::shared_ptr< Features::SubductingPlateModels::Grains::Interface > > &  default_grains_models,
std::vector< std::shared_ptr< Features::SubductingPlateModels::Velocity::Interface > > &  default_velocity_models 
)

Definition at line 1139 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [9/12]

template<>
std::vector<Objects::Segment<Features::FaultModels::Temperature::Interface,Features::FaultModels::Composition::Interface, Features::FaultModels::Grains::Interface, Features::FaultModels::Velocity::Interface> > WorldBuilder::Parameters::get_vector ( const std::string &  name,
std::vector< std::shared_ptr< Features::FaultModels::Temperature::Interface > > &  default_temperature_models,
std::vector< std::shared_ptr< Features::FaultModels::Composition::Interface > > &  default_composition_models,
std::vector< std::shared_ptr< Features::FaultModels::Grains::Interface > > &  default_grains_models,
std::vector< std::shared_ptr< Features::FaultModels::Velocity::Interface > > &  default_velocity_models 
)

Definition at line 1378 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [10/12]

template<>
std::vector<double> WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 1617 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [11/12]

template<>
std::vector<size_t> WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 1659 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector() [12/12]

template<>
std::vector<unsigned int> WorldBuilder::Parameters::get_vector ( const std::string &  name)

Definition at line 1701 of file parameters.cc.

Here is the call graph for this function:

◆ get_vector_or_double()

std::vector< std::vector< double > > WorldBuilder::Parameters::get_vector_or_double ( const std::string &  name)

Definition at line 920 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void WorldBuilder::Parameters::initialize ( std::string &  filename,
bool  has_output_dir = false,
const std::string &  output_dir = "" 
)

Initializes the parameter file

Parameters
filenameA string with the path to the world builder file
has_output_dirA bool indicating whether the world builder may write out information.
output_dirA string with the path to the directory where it can output information if allowed by has_output_dir

Definition at line 88 of file parameters.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ leave_subsection()

void WorldBuilder::Parameters::leave_subsection ( )

This function is used to leave a subsection by removing the last element of the path variable. It reverses the action of the enter subsection function.

See also
path
enter_subsection()

Definition at line 1878 of file parameters.cc.

Here is the caller graph for this function:

Member Data Documentation

◆ coordinate_system

std::unique_ptr<WorldBuilder::CoordinateSystems::Interface> WorldBuilder::Parameters::coordinate_system

A pointers to the corodinate system. This variable is responsible for the coordinate system and has ownership over it. Therefore a unique pointer are used.

See also
CoordinateSystem

Definition at line 268 of file parameters.h.

◆ declarations

rapidjson::Document WorldBuilder::Parameters::declarations

Definition at line 248 of file parameters.h.

◆ features

std::vector<std::unique_ptr<WorldBuilder::Features::Interface> > WorldBuilder::Parameters::features

A vector containing all the pointers to the features. This vector is responsible for the features and has ownership over them. Therefore unique pointers are used.

See also
Features

Definition at line 260 of file parameters.h.

◆ gravity_model

std::unique_ptr<WorldBuilder::GravityModel::Interface> WorldBuilder::Parameters::gravity_model

A pointers to the gravity model. This variable is responsible for the gravity model and has ownership over it. Therefore a unique pointer are used.

See also
CoordinateSystem

Definition at line 276 of file parameters.h.

◆ parameters

rapidjson::Document WorldBuilder::Parameters::parameters

Definition at line 249 of file parameters.h.

◆ path

std::vector<std::string> WorldBuilder::Parameters::path

This variable stores the path in a vector of strings.

See also
enter_subsection()
leave_subsection()

Definition at line 246 of file parameters.h.

◆ path_level

size_t WorldBuilder::Parameters::path_level
private

This function return the current path as stored in the path variable as a string.

Returns
std::string This function return the current path as stored in the path variable as a string, but the arrays are striped. This is useful for working with the boost property tree.
std::string This is used for the get relative path functions. It stores how many top entries of the path should be ignored.

Definition at line 315 of file parameters.h.

◆ path_separator

const std::string WorldBuilder::Parameters::path_separator = "."

This variable stores what path separator is used in the property tree and in this class.

Definition at line 239 of file parameters.h.

◆ world

World& WorldBuilder::Parameters::world

A reference to the World class. This is needed to create the features.

Definition at line 233 of file parameters.h.


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