World Builder  0.1.0-pre
A geodyanmic initial conditions generator
WorldBuilder::Parameters Class Reference

#include <parameters.h>

Collaboration diagram for WorldBuilder::Parameters:

Public Member Functions

 Parameters (std::string &filename, World &)
 
 ~Parameters ()
 
bool load_entry (const std::string &name, const bool required, const Types::Interface &type)
 
bool set_entry (const std::string &name, const Types::Interface &type)
 
void enter_subsection (const std::string name)
 
void leave_subsection ()
 
unsigned int get_unsigned_int (const std::string &name) const
 
double get_double (const std::string &name) const
 
std::string get_string (const std::string &name) const
 
template<int dim>
Point< dim > get_point (const std::string &name) const
 
const Types::Arrayget_array (const std::string &name) const
 
template<class T >
const std::vector< T * > get_array (const std::string &name) const
 
std::string get_full_path () const
 
std::string get_full_path_without_arrays () const
 
template<>
Point< 2 > get_point (const std::string &name) const
 
template<>
Point< 3 > get_point (const std::string &name) const
 

Public Attributes

Worldworld
 
const std::string path_seperator = "."
 
std::vector< std::string > path
 
ptree tree
 
ptree * local_tree
 
std::unordered_map< std::string, unsigned int > string_to_type_map
 
std::vector< Types::UnsignedIntvector_unsigned_int
 
std::vector< Types::Doublevector_double
 
std::vector< Types::Stringvector_string
 
std::vector< Types::Arrayvector_array
 
std::vector< Types::Listvector_list
 
std::vector< Types::Point< 2 > > vector_point_2d
 
std::vector< Types::Point< 3 > > vector_point_3d
 
std::vector< std::unique_ptr< WorldBuilder::Features::Interface > > features
 
std::unique_ptr< WorldBuilder::CoordinateSystems::Interfacecoordinate_system
 

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 70 of file parameters.h.

Constructor & Destructor Documentation

◆ Parameters()

WorldBuilder::Parameters::Parameters ( std::string &  filename,
World world 
)

Constructor

Parameters
filenameA string with the path to the world builder file
worldA reference to the World class

Definition at line 36 of file parameters.cc.

◆ ~Parameters()

WorldBuilder::Parameters::~Parameters ( )

Destructor

Definition at line 52 of file parameters.cc.

Member Function Documentation

◆ 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 495 of file parameters.cc.

Here is the caller graph for this function:

◆ get_array() [1/2]

const Types::Array & WorldBuilder::Parameters::get_array ( const std::string &  name) const

This function retrieves a Type::Array from the parameter class with the key in variable name, based on the path. Note the path rules for called classes explained in the parameter class explanation.

Parameters
nameThe key where the variable is stored. The array contains the underlying type and the indeces where the values are stored.
Returns
Types::Array

Definition at line 551 of file parameters.cc.

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

◆ get_array() [2/2]

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

Returns the array with pointers to the requested type. The reason a raw pointer is returned is that caller is not responsible for the classes pointed at in the return vector or has ownership on them.

Parameters
nameThe key where the variable is stored. The array contains
Returns
std::vector<T*>

Definition at line 562 of file parameters.cc.

Here is the call graph for this function:

◆ get_double()

double WorldBuilder::Parameters::get_double ( const std::string &  name) const

This function retrieves a double from the parameter class with the key in variable name, based on the path. Note the path rules for called classes explained in the parameter class explanation.

Parameters
nameThe key where the variable is stored.

Definition at line 516 of file parameters.cc.

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

◆ get_full_path()

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

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

Returns
std::string

Definition at line 608 of file parameters.cc.

Here is the caller graph for this function:

◆ get_full_path_without_arrays()

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

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.

Returns
std::string

Definition at line 630 of file parameters.cc.

Here is the caller graph for this function:

◆ get_point() [1/3]

template<int dim>
Point<dim> WorldBuilder::Parameters::get_point ( const std::string &  name) const

This function retrieves a point from the parameter class with the key in variable name, based on the path. Note the path rules for called classes explained in the parameter class explanation.

Parameters
nameThe key where the variable is stored.
Returns
Point
Here is the caller graph for this function:

◆ get_point() [2/3]

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

Definition at line 533 of file parameters.cc.

Here is the call graph for this function:

◆ get_point() [3/3]

template<>
template Point< 3 > WorldBuilder::Parameters::get_point< 3 > ( const std::string &  name) const

Definition at line 542 of file parameters.cc.

Here is the call graph for this function:

◆ get_string()

std::string WorldBuilder::Parameters::get_string ( const std::string &  name) const

This function retrieves astring from the parameter class with the key in variable name, based on the path. Note the path rules for called classes explained in the parameter class explanation.

Parameters
nameThe key where the variable is stored.

Definition at line 524 of file parameters.cc.

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

◆ get_unsigned_int()

unsigned int WorldBuilder::Parameters::get_unsigned_int ( const std::string &  name) const

This function retrieves an unsigned int from the parameter class with the key in variable name, based on the path. Note the path rules for called classes explained in the parameter class explanation.

Parameters
nameThe key where the variable is stored.

Definition at line 508 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 502 of file parameters.cc.

Here is the caller graph for this function:

◆ load_entry()

bool WorldBuilder::Parameters::load_entry ( const std::string &  name,
const bool  required,
const Types::Interface type 
)

Loads an entry into the parameter class from the world builder file, where the name is the key in the file relative to the nesting in the world builder file. Note that classes receive the subtree which is relevant for them, so the they only have to account for their nesting.

Note that for the array and list, default values are not implemented.

Parameters
nameThe name of the parameter which should be loaded
requiredDetermines whether a value is required to be present. When it isn't present, and the value is set to true, an assert is thrown. If it is set to false and the value is not found, the default value is used.
typeA value of class Type. Note that these may be nested.
Returns
Returns whether the value was found.
See also
enter_subsection()
leave_subsection()
Types::Interface

Definition at line 56 of file parameters.cc.

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

◆ set_entry()

bool WorldBuilder::Parameters::set_entry ( const std::string &  name,
const Types::Interface type 
)

Sets an entry into the parameter class, where the name is the key in the file relative to the nesting defined by the enter_subsection and leave_subsection functions. Note that classes receive the subtree which is relevant for them, so the they only have to account for their nesting.

Note that for the array and list, default values are not implemented.

See also
enter_subsection()
leave_subsection()
Types::Interface

Definition at line 387 of file parameters.cc.

Here is the call graph for this function:
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 321 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 313 of file parameters.h.

◆ local_tree

ptree* WorldBuilder::Parameters::local_tree

This variable ontains a pointer to the a part of the tree. This variable is not repsonsible for the tree, so using a raw pointer.

See also
tree

Definition at line 228 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 215 of file parameters.h.

◆ path_seperator

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

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

Definition at line 208 of file parameters.h.

◆ string_to_type_map

std::unordered_map<std::string,unsigned int> WorldBuilder::Parameters::string_to_type_map

An unordered map used to store and retrieve the indices where the variables in this class are stored based on the path key.

See also
path
get_current_path()

Definition at line 236 of file parameters.h.

◆ tree

ptree WorldBuilder::Parameters::tree

The boost property tree, used to read in the data from a json file.

Definition at line 221 of file parameters.h.

◆ vector_array

std::vector<Types::Array> WorldBuilder::Parameters::vector_array

A vector which stores all the Array types. These can be retrieved with the help of the string_to_type_map and the get_array() function.

See also
string_to_type_map
get_array()
Types::Array

Definition at line 276 of file parameters.h.

◆ vector_double

std::vector<Types::Double> WorldBuilder::Parameters::vector_double

A vector which stores all the Double types. These can be retrieved with the help of the string_to_type_map and the get_double() function.

See also
string_to_type_map
get_double()
Types::Double

Definition at line 256 of file parameters.h.

◆ vector_list

std::vector<Types::List> WorldBuilder::Parameters::vector_list

A vector which stores all the List types. These can be retrieved with the help of the string_to_type_map.

See also
string_to_type_map
Types::List

Definition at line 284 of file parameters.h.

◆ vector_point_2d

std::vector<Types::Point<2> > WorldBuilder::Parameters::vector_point_2d

A vector which stores all the Point<2> types. These can be retrieved with the help of the string_to_type_map and the get_Point<2>() function.

See also
string_to_type_map
get_point<2>()
Types::Point

Definition at line 294 of file parameters.h.

◆ vector_point_3d

std::vector<Types::Point<3> > WorldBuilder::Parameters::vector_point_3d

A vector which stores all the Point<3> types. These can be retrieved with the help of the string_to_type_map and the get_Point<3>() function.

See also
string_to_type_map
get_point<3>()
Types::Point

Definition at line 304 of file parameters.h.

◆ vector_string

std::vector<Types::String> WorldBuilder::Parameters::vector_string

A vector which stores all the String types. These can be retrieved with the help of the string_to_type_map and the get_string() function.

See also
string_to_type_map
get_unsigned_int()
Types::UnsignedInt

Definition at line 266 of file parameters.h.

◆ vector_unsigned_int

std::vector<Types::UnsignedInt> WorldBuilder::Parameters::vector_unsigned_int

A vector which stores all the UnsignedInt types. These can be retrieved with the help of the string_to_type_map and the get_unsigned_int() function.

See also
string_to_type_map
get_unsigned_int()
Types::UnsignedInt

Definition at line 246 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 202 of file parameters.h.


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