MoCSI API Reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
InputManager Class Reference

This class that manages parameter input through the default ini and user supplied ini files + CLI. Parses the supplied data into strings, ints, doubles and bools and makes them accessable through getter-functions. More...

#include <InputManager.h>

Collaboration diagram for InputManager:
Collaboration graph

Public Member Functions

 InputManager ()
 Constructor for the InputManager class. Used in case the file can only be passed at runtime.
 
 InputManager (const std::string &default_ini_file_path)
 Constructor for the InputManager class.
 
void loadUserInput (const std::string &user_ini_file_path)
 Public function to load and merge user supplied ini files with the already stored data.
 
void parseCommandLineArguments (int argc, const char *argv[], const std::string &user_ini_path)
 
int getIntParameters (const std::string &key) const
 Getter function to access the m_intParameters map and returns an int.
 
double getDoubleParameters (const std::string &key) const
 Getter function to access the m_DoubleParameters map and returns a double.
 
bool getBoolParameters (const std::string &key) const
 Getter function to access the m_parameters map and returns a bool. Throws a BadInput error, if the accessed key doesn't exist. Throws a BadInput error, if the value being accessed can't be unambiguously pared to bool. Unambiguous bool values are "true", "false", "1", "0".
 
std::string getStringParameters (const std::string &key) const
 Getter function to access the m_parameters map and returns a string. Throws a BadInput error, if the accessed key doesn't exist.
 
std::vector< std::string > getStringVectorParameters (const std::string &key) const
 
std::vector< doublegetDoubleVectorParameters (const std::string &key) const
 
void printInput () const
 Function that prints the current content of m_parameters to the console.
 
void addBuildInfo ()
 Adds build metadata to the simulation configuration.
 
void forceValueOverwrite (const std::string &key, const std::string &value)
 
std::unordered_map< std::string, std::any > data ()
 

Detailed Description

This class that manages parameter input through the default ini and user supplied ini files + CLI. Parses the supplied data into strings, ints, doubles and bools and makes them accessable through getter-functions.

Constructor & Destructor Documentation

◆ InputManager() [1/2]

InputManager::InputManager ( )

Constructor for the InputManager class. Used in case the file can only be passed at runtime.

◆ InputManager() [2/2]

InputManager::InputManager ( const std::string &  default_ini_file_path)

Constructor for the InputManager class.

Parameters
default_ini_file_pathThe path to the default ini file. Always needs to be supplied!

Member Function Documentation

◆ addBuildInfo()

void InputManager::addBuildInfo ( )

Adds build metadata to the simulation configuration.

This function injects compile-time build information into the internal parameter map. The metadata includes:

  • Project version (PROJECT_VERSION)
  • Git branch, tags, and commit hash (GIT_REVISION)

These parameters are added as the following keys "build.version" and "build.git".

Note
This function internally calls the private updateKeys() method to merge the new parameters into the interal parameter map.

◆ data()

std::unordered_map< std::string, std::any > InputManager::data ( )
inline

◆ forceValueOverwrite()

void InputManager::forceValueOverwrite ( const std::string &  key,
const std::string &  value 
)

◆ getBoolParameters()

bool InputManager::getBoolParameters ( const std::string &  key) const

Getter function to access the m_parameters map and returns a bool. Throws a BadInput error, if the accessed key doesn't exist. Throws a BadInput error, if the value being accessed can't be unambiguously pared to bool. Unambiguous bool values are "true", "false", "1", "0".

Parameters
keyThe key whose value should be returned.

◆ getDoubleParameters()

double InputManager::getDoubleParameters ( const std::string &  key) const

Getter function to access the m_DoubleParameters map and returns a double.

Exceptions
Throwsa BadInput error, if the accessed key doesn't exist.
Parameters
keyThe key whose value should be returned.

◆ getDoubleVectorParameters()

std::vector< double > InputManager::getDoubleVectorParameters ( const std::string &  key) const

◆ getIntParameters()

int InputManager::getIntParameters ( const std::string &  key) const

Getter function to access the m_intParameters map and returns an int.

Exceptions
Throwsa BadInput error, if the accessed key doesn't exist.
Parameters
keyThe key whose value should be returned.

◆ getStringParameters()

std::string InputManager::getStringParameters ( const std::string &  key) const

Getter function to access the m_parameters map and returns a string. Throws a BadInput error, if the accessed key doesn't exist.

Parameters
keyThe key whose value should be returned.

◆ getStringVectorParameters()

std::vector< std::string > InputManager::getStringVectorParameters ( const std::string &  key) const

◆ loadUserInput()

void InputManager::loadUserInput ( const std::string &  user_ini_file_path)

Public function to load and merge user supplied ini files with the already stored data.

Parameters
user_ini_file_pathThe path to the new user supplied ini file.

◆ parseCommandLineArguments()

void InputManager::parseCommandLineArguments ( int  argc,
const char argv[],
const std::string &  user_ini_path 
)

◆ printInput()

void InputManager::printInput ( ) const

Function that prints the current content of m_parameters to the console.


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