OOFEM 3.0
Loading...
Searching...
No Matches
oofem::ParameterManager Class Reference

#include <parametermanager.h>

Public Types

using paramValue = std::variant<int, double, std::string, bool, IntArray, FloatArray, FloatMatrix>

Public Member Functions

void setPriority (size_t componentIndex, size_t paramIndex, int priority)
int getPriority (size_t componentIndex, size_t paramIndex) const
void clear ()
bool checkIfSet (size_t componentIndex, size_t paramIndex)
void setTemParam (size_t componentIndex, size_t paramIndex, const paramValue &value)
std::optional< paramValuegetTempParam (size_t componentIndex, size_t paramIndex) const
bool hasTempParam (size_t componentIndex, size_t paramIndex) const

Private Attributes

std::vector< std::unordered_map< size_t, int > > priorities
std::shared_mutex mtx
std::vector< std::unordered_map< size_t, paramValue > > tempParams

Detailed Description

ParameterPriorityManager class manages the actual priority for parameters that can be set from multiple sources, typically from component record or via set. It allows setting and getting parameters with a priority system, where higher priority values override lower priority ones. The manager manages parameters for multiple components, each identified by a unique index. The parameters are stored in a shared map, where the key is a string representing the parameter name and the value is a the parameter index. It uses a shared mutex for thread-safe access to the parameters. The class is designed to be used in a multi-threaded environment where multiple threads may attempt to set or get parameters simultaneously. The class provides methods to register parameters, set their priorities, and retrieve their priorities for a collection of components.

It also allows to manage temporary parameters for each component which can be set and retrieved. The temporary params are handy for pattern with multi-source initialization and single finalization.

Definition at line 130 of file parametermanager.h.

Member Typedef Documentation

◆ paramValue

using oofem::ParameterManager::paramValue = std::variant<int, double, std::string, bool, IntArray, FloatArray, FloatMatrix>

Definition at line 132 of file parametermanager.h.

Member Function Documentation

◆ checkIfSet()

◆ clear()

void oofem::ParameterManager::clear ( )
inline

Definition at line 150 of file parametermanager.h.

References mtx, priorities, and tempParams.

◆ getPriority()

int oofem::ParameterManager::getPriority ( size_t componentIndex,
size_t paramIndex ) const
inline

Definition at line 141 of file parametermanager.h.

References mtx, and priorities.

◆ getTempParam()

std::optional< paramValue > oofem::ParameterManager::getTempParam ( size_t componentIndex,
size_t paramIndex ) const
inline

◆ hasTempParam()

bool oofem::ParameterManager::hasTempParam ( size_t componentIndex,
size_t paramIndex ) const
inline

Definition at line 181 of file parametermanager.h.

References mtx, and tempParams.

◆ setPriority()

void oofem::ParameterManager::setPriority ( size_t componentIndex,
size_t paramIndex,
int priority )
inline

Definition at line 133 of file parametermanager.h.

References mtx, and priorities.

◆ setTemParam()

void oofem::ParameterManager::setTemParam ( size_t componentIndex,
size_t paramIndex,
const paramValue & value )
inline

Definition at line 165 of file parametermanager.h.

References mtx, and tempParams.

Member Data Documentation

◆ mtx

std::shared_mutex oofem::ParameterManager::mtx
mutableprivate

◆ priorities

std::vector<std::unordered_map<size_t, int> > oofem::ParameterManager::priorities
private

Definition at line 188 of file parametermanager.h.

Referenced by checkIfSet(), clear(), getPriority(), and setPriority().

◆ tempParams

std::vector<std::unordered_map<size_t, paramValue> > oofem::ParameterManager::tempParams
private

Definition at line 191 of file parametermanager.h.

Referenced by clear(), getTempParam(), hasTempParam(), and setTemParam().


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

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011