SERiF 0.0.1a
3+1D Stellar Structure and Evolution
Loading...
Searching...
No Matches
serif::constant::Constants Class Reference

Class to manage a collection of constants. More...

#include <const.h>

Public Member Functions

bool isLoaded () const
 Check if constants are loaded.
 
Constant get (const std::string &key) const
 Get a constant by key.
 
Constant operator[] (const std::string &key) const
 Overloaded subscript operator to access constants by key.
 
bool has (const std::string &key) const
 Check if a constant exists by key.
 
std::set< std::string > keys () const
 Get a list of all constant keys.
 

Static Public Member Functions

static ConstantsgetInstance ()
 get instance of constants singleton
 

Private Member Functions

 Constants ()
 Default constructor. Private to avoid direct instantiation.
 
bool load ()
 Load constants from the embedded header file.
 
bool initialize ()
 Initialize constants.
 
std::string trim (const std::string &str)
 Trim leading and trailing whitespace from a string.
 

Private Attributes

bool loaded_ = false
 Flag to indicate if constants are loaded.
 
const int col_widths_ [6] = {25, 52, 20, 20, 17, 45}
 
std::map< std::string, Constantconstants_
 Map to store constants by name.
 

Detailed Description

Class to manage a collection of constants.

Definition at line 63 of file const.h.

Constructor & Destructor Documentation

◆ Constants()

serif::constant::Constants::Constants ( )
private

Default constructor. Private to avoid direct instantiation.

Definition at line 34 of file const.cpp.

Member Function Documentation

◆ get()

Constant serif::constant::Constants::get ( const std::string & key) const

Get a constant by key.

Parameters
keyThe name of the constant to retrieve.
Returns
The constant associated with the given key.

Definition at line 42 of file const.cpp.

◆ getInstance()

static Constants & serif::constant::Constants::getInstance ( )
inlinestatic

get instance of constants singleton

Returns
instance of constants

Definition at line 99 of file const.h.

◆ has()

bool serif::constant::Constants::has ( const std::string & key) const

Check if a constant exists by key.

Parameters
keyThe name of the constant to check.
Returns
True if the constant exists, false otherwise.

Definition at line 55 of file const.cpp.

◆ initialize()

bool serif::constant::Constants::initialize ( )
private

Initialize constants.

Returns
True if initialization was successful, false otherwise.

Definition at line 38 of file const.cpp.

◆ isLoaded()

bool serif::constant::Constants::isLoaded ( ) const
inline

Check if constants are loaded.

Returns
True if constants are loaded, false otherwise.

Definition at line 108 of file const.h.

◆ keys()

std::set< std::string > serif::constant::Constants::keys ( ) const

Get a list of all constant keys.

Returns
A vector of all constant keys.

Definition at line 59 of file const.cpp.

◆ load()

bool serif::constant::Constants::load ( )
private

Load constants from the embedded header file.

Returns
True if loading was successful, false otherwise.

Definition at line 74 of file const.cpp.

◆ operator[]()

Constant serif::constant::Constants::operator[] ( const std::string & key) const

Overloaded subscript operator to access constants by key.

Parameters
keyThe name of the constant to retrieve.
Returns
The constant associated with the given key.
Exceptions
std::out_of_rangeif the key is not found.

Definition at line 51 of file const.cpp.

◆ trim()

std::string serif::constant::Constants::trim ( const std::string & str)
private

Trim leading and trailing whitespace from a string.

Parameters
strThe string to trim.
Returns
The trimmed string.

Definition at line 67 of file const.cpp.

Member Data Documentation

◆ col_widths_

const int serif::constant::Constants::col_widths_[6] = {25, 52, 20, 20, 17, 45}
private

Definition at line 66 of file const.h.

◆ constants_

std::map<std::string, Constant> serif::constant::Constants::constants_
private

Map to store constants by name.

Definition at line 67 of file const.h.

◆ loaded_

bool serif::constant::Constants::loaded_ = false
private

Flag to indicate if constants are loaded.

Definition at line 65 of file const.h.


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