Chi-Tech
chi_physics::BasicOptions Class Reference

#include <basic_options.h>

Public Member Functions

 BasicOptions ()=default
 
 BasicOptions (std::initializer_list< BasicOption > in_options)
 
const BasicOptionoperator() (const std::string &option_name) const
 
const BasicOptionoperator() (size_t index) const
 
BasicOptionoperator[] (const std::string &option_name)
 
BasicOptionoperator[] (size_t index)
 
template<typename T >
void AddOption (const std::string &option_name, const T &value)
 
size_t GetOptionIndexFromName (const std::string &option_name) const
 
template<>
void AddOption (const std::string &option_name, const bool &value)
 
template<>
void AddOption (const std::string &option_name, const int64_t &value)
 
template<>
void AddOption (const std::string &option_name, const double &value)
 

Private Attributes

std::vector< BasicOptionoptions_
 

Detailed Description

Class for basic options

Definition at line 46 of file basic_options.h.

Constructor & Destructor Documentation

◆ BasicOptions() [1/2]

chi_physics::BasicOptions::BasicOptions ( )
default

◆ BasicOptions() [2/2]

chi_physics::BasicOptions::BasicOptions ( std::initializer_list< BasicOption in_options)
inline

Constructor with initializer list.

Definition at line 55 of file basic_options.h.

Member Function Documentation

◆ AddOption() [1/4]

template<>
void chi_physics::BasicOptions::AddOption ( const std::string &  option_name,
const bool &  value 
)

Definition at line 73 of file basic_options.cc.

◆ AddOption() [2/4]

template<>
void chi_physics::BasicOptions::AddOption ( const std::string &  option_name,
const double &  value 
)

Definition at line 87 of file basic_options.cc.

◆ AddOption() [3/4]

template<>
void chi_physics::BasicOptions::AddOption ( const std::string &  option_name,
const int64_t &  value 
)

Definition at line 80 of file basic_options.cc.

◆ AddOption() [4/4]

template<typename T >
void chi_physics::BasicOptions::AddOption ( const std::string &  option_name,
const T &  value 
)

◆ GetOptionIndexFromName()

size_t chi_physics::BasicOptions::GetOptionIndexFromName ( const std::string &  option_name) const

Attempts to find an option that matches the requested name. If one is found then its corresponding index is returned. If it is not found then a std::out_of_range exception is thrown.

Definition at line 97 of file basic_options.cc.

◆ operator()() [1/2]

const chi_physics::BasicOption & chi_physics::BasicOptions::operator() ( const std::string &  option_name) const

Returns a constant reference to an option that matches the requested name. If no name-match is found the method will throw a std::out_of_range exception.

Definition at line 6 of file basic_options.cc.

◆ operator()() [2/2]

const chi_physics::BasicOption & chi_physics::BasicOptions::operator() ( size_t  index) const

Returns a constant reference to an option at the given index. If the index is out of range then a std::out_of_range exception is thrown. This method can potentially be faster than the string comparison equivalent.

Definition at line 23 of file basic_options.cc.

◆ operator[]() [1/2]

chi_physics::BasicOption & chi_physics::BasicOptions::operator[] ( const std::string &  option_name)

Returns a non-constant reference to an option that matches the requested name. If no name-match is found the method will throw a std::out_of_range exception.

Definition at line 36 of file basic_options.cc.

◆ operator[]() [2/2]

chi_physics::BasicOption & chi_physics::BasicOptions::operator[] ( size_t  index)

Returns a non-constant reference to an option at the given index. If the index is out of range then a std::out_of_range exception is thrown. This method can potentially be faster than the string comparison equivalent.

Definition at line 53 of file basic_options.cc.

Field Documentation

◆ options_

std::vector<BasicOption> chi_physics::BasicOptions::options_
private

Definition at line 49 of file basic_options.h.


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