Chi-Tech
chi::InputParameters Class Reference

#include <input_parameters.h>

Inheritance diagram for chi::InputParameters:
chi::ParameterBlock

Public Member Functions

 InputParameters ()=default
 
InputParametersoperator+= (InputParameters other)
 
void SetObjectType (const std::string &obj_type)
 
std::string ObjectType () const
 
void SetClassName (const std::string &class_name)
 
void SetGeneralDescription (const std::string &description)
 
std::string GetGeneralDescription () const
 
void SetDocGroup (const std::string &doc_group)
 
void LinkParameterToBlock (const std::string &param_name, const std::string &block_name)
 
std::string GetParameterDocumentationLink (const std::string &param_name) const
 
std::string GetParameterDocString (const std::string &param_name)
 
template<typename T >
void AddOptionalParameter (const std::string &name, T value, const std::string &doc_string)
 
void AddOptionalParameterBlock (const std::string &name, const ParameterBlock &block, const std::string &doc_string)
 
template<typename T >
void AddOptionalParameterArray (const std::string &name, const std::vector< T > &array, const std::string &doc_string)
 
void AddOptionalParameterArray (const std::string &name, const std::vector< ParameterBlock > &array, const std::string &doc_string)
 
template<typename T >
void AddRequiredParameter (const std::string &name, const std::string &doc_string)
 
void AddRequiredParameterBlock (const std::string &name, const std::string &doc_string)
 
void AddRequiredParameterArray (const std::string &name, const std::string &doc_string)
 
template<typename T >
void ChangeExistingParamToOptional (const std::string &name, T value, const std::string &doc_string="")
 
template<typename T >
void ChangeExistingParamToRequired (const std::string &name, const std::string &doc_string="")
 
void AssignParameters (const ParameterBlock &params)
 Assigns parameters with thorough type checks, deprecation checks, unused parameter checks. More...
 
const ParameterBlockParametersAtAssignment () const
 
void MarkParamaterDeprecatedWarning (const std::string &param_name, const std::string &deprecation_message="")
 
void MarkParamaterDeprecatedError (const std::string &param_name, const std::string &deprecation_message="")
 
void MarkParamaterRenamed (const std::string &param_name, const std::string &renaming_description)
 
void ConstrainParameterRange (const std::string &param_name, AllowableRangePtr allowable_range)
 
void SetParameterTypeMismatchAllowed (const std::string &param_name)
 Sets a tag for the given parameter that will allow its type to be mismatched upon assignment. More...
 
void DumpParameters () const
 
- Public Member Functions inherited from chi::ParameterBlock
void SetBlockName (const std::string &name)
 
 ParameterBlock (const std::string &name="")
 
template<typename T >
 ParameterBlock (const std::string &name, const std::vector< T > &array)
 
template<typename T >
 ParameterBlock (const std::string &name, T value)
 
 ParameterBlock (const ParameterBlock &other)
 
ParameterBlockoperator= (const ParameterBlock &other)
 
 ParameterBlock (ParameterBlock &&other) noexcept
 
ParameterBlockoperator= (ParameterBlock &&other) noexcept
 
ParameterBlockType Type () const
 
bool IsScalar () const
 
std::string TypeName () const
 
std::string Name () const
 
const chi_data_types::VaryingValue () const
 
size_t NumParameters () const
 
const std::vector< ParameterBlock > & Parameters () const
 
bool HasValue () const
 
void ChangeToArray ()
 
void SetErrorOriginScope (const std::string &scope)
 
std::string GetErrorOriginScope () const
 
void RequireBlockTypeIs (ParameterBlockType type) const
 
void RequireParameterBlockTypeIs (const std::string &param_name, ParameterBlockType type) const
 
void RequireParameter (const std::string &param_name) const
 
void AddParameter (ParameterBlock block)
 
template<typename T >
void AddParameter (const std::string &name, T value)
 
void SortParameters ()
 
bool Has (const std::string &param_name) const
 
ParameterBlockGetParam (const std::string &param_name)
 
ParameterBlockGetParam (size_t index)
 
const ParameterBlockGetParam (const std::string &param_name) const
 
const ParameterBlockGetParam (size_t index) const
 
template<typename T >
GetValue () const
 
template<typename T >
GetParamValue (const std::string &param_name) const
 
template<typename T >
std::vector< T > GetVectorValue () const
 
template<typename T >
std::vector< T > GetParamVectorValue (const std::string &param_name) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void RecursiveDumpToString (std::string &outstr, const std::string &offset="") const
 
void RecursiveDumpToJSON (std::string &outstr) const
 

Static Public Member Functions

template<typename T >
static InputParameters MakeForObject (const ParameterBlock &params)
 

Private Types

typedef std::unique_ptr< chi_data_types::AllowableRangeAllowableRangePtr
 

Private Member Functions

void AddParameter (ParameterBlock block)
 
template<typename T >
void AddParameter (const std::string &name, T value)
 

Static Private Member Functions

static bool IsParameterIgnored (const std::string &param_name)
 

Private Attributes

std::string class_name_
 
std::string doc_group_
 
std::map< std::string, InputParameterTagparameter_class_tags_
 
std::map< std::string, std::string > parameter_doc_string_
 
std::map< std::string, std::string > deprecation_warning_tags_
 
std::map< std::string, std::string > deprecation_error_tags_
 
std::map< std::string, std::string > renamed_error_tags_
 
std::map< std::string, bool > type_mismatch_allowed_tags_
 
std::map< std::string, std::string > parameter_link_
 
std::map< std::string, AllowableRangePtrconstraint_tags_
 
std::string general_description_
 
ParameterBlock param_block_at_assignment_
 

Static Private Attributes

static const std::vector< std::string > system_ignored_param_names_
 

Detailed Description

Class for handling input parameters.

Definition at line 22 of file input_parameters.h.

Member Typedef Documentation

◆ AllowableRangePtr

Definition at line 39 of file input_parameters.h.

Constructor & Destructor Documentation

◆ InputParameters()

chi::InputParameters::InputParameters ( )
default

Member Function Documentation

◆ AddOptionalParameter()

template<typename T >
void chi::InputParameters::AddOptionalParameter ( const std::string &  name,
value,
const std::string &  doc_string 
)
inline

Definition at line 97 of file input_parameters.h.

◆ AddOptionalParameterArray() [1/2]

void chi::InputParameters::AddOptionalParameterArray ( const std::string &  name,
const std::vector< ParameterBlock > &  array,
const std::string &  doc_string 
)

Specialization for block type parameters.

Definition at line 187 of file input_parameters.cc.

◆ AddOptionalParameterArray() [2/2]

template<typename T >
void chi::InputParameters::AddOptionalParameterArray ( const std::string &  name,
const std::vector< T > &  array,
const std::string &  doc_string 
)
inline

Definition at line 111 of file input_parameters.h.

◆ AddOptionalParameterBlock()

void chi::InputParameters::AddOptionalParameterBlock ( const std::string &  name,
const ParameterBlock block,
const std::string &  doc_string 
)

Specialization for block type parameters.

Definition at line 174 of file input_parameters.cc.

◆ AddParameter() [1/2]

template<typename T >
void chi::ParameterBlock::AddParameter ( const std::string &  name,
value 
)
inlineprivate

Makes a ParameterBlock and adds it to the sub-parameters list.

Definition at line 168 of file parameter_block.h.

◆ AddParameter() [2/2]

void chi::ParameterBlock::AddParameter ( ParameterBlock  block)
private

Adds a parameter to the sub-parameter list.

Definition at line 165 of file paramater_block.cc.

◆ AddRequiredParameter()

template<typename T >
void chi::InputParameters::AddRequiredParameter ( const std::string &  name,
const std::string &  doc_string 
)
inline

Definition at line 125 of file input_parameters.h.

◆ AddRequiredParameterArray()

void chi::InputParameters::AddRequiredParameterArray ( const std::string &  name,
const std::string &  doc_string 
)

Specialization for array type parameters.

Definition at line 215 of file input_parameters.cc.

◆ AddRequiredParameterBlock()

void chi::InputParameters::AddRequiredParameterBlock ( const std::string &  name,
const std::string &  doc_string 
)

Specialization for block type parameters.

Definition at line 204 of file input_parameters.cc.

◆ AssignParameters()

void chi::InputParameters::AssignParameters ( const ParameterBlock params)

Assigns parameters with thorough type checks, deprecation checks, unused parameter checks.

Returns an error string if the check has not passed. This method first checks whether all the required parameters are supplied. Then it checks that all the parameters supplied actually maps to valid parameters.

Definition at line 230 of file input_parameters.cc.

◆ ChangeExistingParamToOptional()

template<typename T >
void chi::InputParameters::ChangeExistingParamToOptional ( const std::string &  name,
value,
const std::string &  doc_string = "" 
)
inline

Definition at line 140 of file input_parameters.h.

◆ ChangeExistingParamToRequired()

template<typename T >
void chi::InputParameters::ChangeExistingParamToRequired ( const std::string &  name,
const std::string &  doc_string = "" 
)
inline

Definition at line 151 of file input_parameters.h.

◆ ConstrainParameterRange()

void chi::InputParameters::ConstrainParameterRange ( const std::string &  param_name,
AllowableRangePtr  allowable_range 
)

Creates a range based constraint for a given parameter.

Definition at line 407 of file input_parameters.cc.

◆ DumpParameters()

void chi::InputParameters::DumpParameters ( ) const

Dumps the input parameters to stdout.

Definition at line 438 of file input_parameters.cc.

◆ GetGeneralDescription()

std::string chi::InputParameters::GetGeneralDescription ( ) const
inline

Definition at line 76 of file input_parameters.h.

◆ GetParameterDocString()

std::string chi::InputParameters::GetParameterDocString ( const std::string &  param_name)

Returns the parameter's doc string.

Definition at line 150 of file input_parameters.cc.

◆ GetParameterDocumentationLink()

std::string chi::InputParameters::GetParameterDocumentationLink ( const std::string &  param_name) const

Gets any linkage information of a parameter.

Definition at line 139 of file input_parameters.cc.

◆ IsParameterIgnored()

bool chi::InputParameters::IsParameterIgnored ( const std::string &  param_name)
staticprivate

Determines if a parameter is ignored.

Definition at line 159 of file input_parameters.cc.

◆ LinkParameterToBlock()

void chi::InputParameters::LinkParameterToBlock ( const std::string &  param_name,
const std::string &  block_name 
)

Sets a link to the documentation of a different object.

Definition at line 129 of file input_parameters.cc.

◆ MakeForObject()

template<typename T >
static InputParameters chi::InputParameters::MakeForObject ( const ParameterBlock params)
inlinestatic

Definition at line 54 of file input_parameters.h.

◆ MarkParamaterDeprecatedError()

void chi::InputParameters::MarkParamaterDeprecatedError ( const std::string &  param_name,
const std::string &  deprecation_message = "" 
)

Marks a parameters as deprecated and will produce an error if the parameter is specified.

Definition at line 385 of file input_parameters.cc.

◆ MarkParamaterDeprecatedWarning()

void chi::InputParameters::MarkParamaterDeprecatedWarning ( const std::string &  param_name,
const std::string &  deprecation_message = "" 
)

Marks a parameters as deprecated but will only produce a warning.

Definition at line 373 of file input_parameters.cc.

◆ MarkParamaterRenamed()

void chi::InputParameters::MarkParamaterRenamed ( const std::string &  param_name,
const std::string &  renaming_description 
)

Marks a parameters as renamed and will produce an error if the parameter is specified.

Definition at line 397 of file input_parameters.cc.

◆ ObjectType()

std::string chi::InputParameters::ObjectType ( ) const

Returns the object type string.

Definition at line 125 of file input_parameters.cc.

◆ operator+=()

InputParameters & chi::InputParameters::operator+= ( InputParameters  other)

Definition at line 26 of file input_parameters.cc.

◆ ParametersAtAssignment()

const ParameterBlock & chi::InputParameters::ParametersAtAssignment ( ) const
inline

Returns the raw parameter block used at assignment. This can be used to see if a user supplied an optional parameter or not.

Definition at line 167 of file input_parameters.h.

◆ SetClassName()

void chi::InputParameters::SetClassName ( const std::string &  class_name)
inline

Sets the class name to be applied to this object. If not used a default will be generated.

Definition at line 68 of file input_parameters.h.

◆ SetDocGroup()

void chi::InputParameters::SetDocGroup ( const std::string &  doc_group)
inline

Space separated list of doxygen group names to which this documentation should belong.

Definition at line 80 of file input_parameters.h.

◆ SetGeneralDescription()

void chi::InputParameters::SetGeneralDescription ( const std::string &  description)
inline

Sets a general description of the object that should be included with the object's documentation.

Definition at line 72 of file input_parameters.h.

◆ SetObjectType()

void chi::InputParameters::SetObjectType ( const std::string &  obj_type)

Sets the object type string for more descriptive error messages.

Definition at line 118 of file input_parameters.cc.

◆ SetParameterTypeMismatchAllowed()

void chi::InputParameters::SetParameterTypeMismatchAllowed ( const std::string &  param_name)

Sets a tag for the given parameter that will allow its type to be mismatched upon assignment.

Useful for accepting varying datatypes or making a choice based upon the type of a parameter.

Definition at line 428 of file input_parameters.cc.

Field Documentation

◆ class_name_

std::string chi::InputParameters::class_name_
private

String to represent class name. If not provided a default will be generated.

Definition at line 27 of file input_parameters.h.

◆ constraint_tags_

std::map<std::string, AllowableRangePtr> chi::InputParameters::constraint_tags_
private

Definition at line 40 of file input_parameters.h.

◆ deprecation_error_tags_

std::map<std::string, std::string> chi::InputParameters::deprecation_error_tags_
private

Definition at line 34 of file input_parameters.h.

◆ deprecation_warning_tags_

std::map<std::string, std::string> chi::InputParameters::deprecation_warning_tags_
private

Definition at line 33 of file input_parameters.h.

◆ doc_group_

std::string chi::InputParameters::doc_group_
private

Space separated list of group names.

Definition at line 29 of file input_parameters.h.

◆ general_description_

std::string chi::InputParameters::general_description_
private

Definition at line 42 of file input_parameters.h.

◆ param_block_at_assignment_

ParameterBlock chi::InputParameters::param_block_at_assignment_
private

Definition at line 48 of file input_parameters.h.

◆ parameter_class_tags_

std::map<std::string, InputParameterTag> chi::InputParameters::parameter_class_tags_
private

Definition at line 30 of file input_parameters.h.

◆ parameter_doc_string_

std::map<std::string, std::string> chi::InputParameters::parameter_doc_string_
private

Definition at line 31 of file input_parameters.h.

◆ parameter_link_

std::map<std::string, std::string> chi::InputParameters::parameter_link_
private

Definition at line 37 of file input_parameters.h.

◆ renamed_error_tags_

std::map<std::string, std::string> chi::InputParameters::renamed_error_tags_
private

Definition at line 35 of file input_parameters.h.

◆ system_ignored_param_names_

const std::vector< std::string > chi::InputParameters::system_ignored_param_names_
staticprivate
Initial value:
= {
"chi_obj_type"}

Parameter names to ignore when trying to assign. For now this "chi_obj_type"

Definition at line 46 of file input_parameters.h.

◆ type_mismatch_allowed_tags_

std::map<std::string, bool> chi::InputParameters::type_mismatch_allowed_tags_
private

Definition at line 36 of file input_parameters.h.


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