Iguana 0.9.0
Implementation Guardian of Analysis Algorithms
Loading...
Searching...
No Matches
iguana::ConfigFileReader Class Reference

#include <ConfigFileReader.h>

Detailed Description

Configuration file manager.

Definition at line 9 of file ConfigFileReader.h.

Public Member Functions

 ConfigFileReader (std::string_view name="config")
void AddDirectory (std::string const &dir)
void AddFile (std::string const &name)
void PrintDirectories (Logger::Level const level=Logger::info)
std::string FindFile (std::string const &name)
Public Member Functions inherited from iguana::Object
 Object (std::string_view name="", Logger::Level lev=Logger::DEFAULT_LEVEL)
std::unique_ptr< Logger > & Log ()
void SetName (std::string_view name)
std::string GetName () const
void SetLogLevel (std::string_view lev)
void SetLogLevel (Logger::Level const lev)
std::unique_ptr< Logger > & GetLog ()

Static Public Member Functions

static std::string GetConfigInstallationPrefix ()
static std::string ConvertAlgoNameToConfigName (std::string_view algo_name, std::string_view ext="yaml")

Protected Attributes

std::deque< std::string > m_directories
 Stack of directories to search for a file.
std::deque< std::string > m_files
 Stack of file names to parse.
Protected Attributes inherited from iguana::Object
std::string m_name
 The name of this object.
std::unique_ptr< Loggerm_log
 Logger instance for this object
Inheritance diagram for iguana::ConfigFileReader:
Inheritance graph

Constructor & Destructor Documentation

◆ ConfigFileReader()

iguana::ConfigFileReader::ConfigFileReader ( std::string_view name = "config")
Parameters
namethe name of this configuration file handler

Member Function Documentation

◆ AddDirectory()

void iguana::ConfigFileReader::AddDirectory ( std::string const & dir)

Add a directory to the configuration files' search paths.

Parameters
dirthe directory, which may be relative or absolute

◆ AddFile()

void iguana::ConfigFileReader::AddFile ( std::string const & name)

Add a configuration file to be parsed

Parameters
namethe name of the file

◆ ConvertAlgoNameToConfigName()

std::string iguana::ConfigFileReader::ConvertAlgoNameToConfigName ( std::string_view algo_name,
std::string_view ext = "yaml" )
static

Convert a full algorithm name to its corresponding default config file name

Parameters
algo_namethe algorithm name
extthe file extension
Returns
the config file name

◆ FindFile()

std::string iguana::ConfigFileReader::FindFile ( std::string const & name)

Find a configuration file by name. You may either give just a file name, or specify the full path and filename. The following locations are searched, in order:

  • current working directory ./
  • directories included by ConfigFileReader::AddDirectory, starting from the most recently added directory
  • the common installation prefix
    Parameters
    namethe configuration file name (with or without a directory)
    Returns
    the found configuration file (with the directory)

◆ GetConfigInstallationPrefix()

std::string iguana::ConfigFileReader::GetConfigInstallationPrefix ( )
static

Get the config files' fixed installation prefix

Warning
if the Iguana installation is relocated, this directory will not be correct, since it is compiled in the shared library; as a fallback, you may use the environment variable $IGUANA_CONFIG_PATH.
Returns
the absolute path to the installed configuration file directory

◆ PrintDirectories()

void iguana::ConfigFileReader::PrintDirectories ( Logger::Level const level = Logger::info)

Print the list of directories (search path)

Parameters
levelthe log level

Member Data Documentation

◆ m_directories

std::deque<std::string> iguana::ConfigFileReader::m_directories
protected

Stack of directories to search for a file.

Definition at line 54 of file ConfigFileReader.h.

◆ m_files

std::deque<std::string> iguana::ConfigFileReader::m_files
protected

Stack of file names to parse.

Definition at line 57 of file ConfigFileReader.h.


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