OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SDDS::SDDSParser Class Reference

#include <SDDSParser.h>

Inheritance diagram for SDDS::SDDSParser:
Inheritance graph
[legend]
Collaboration diagram for SDDS::SDDSParser:
Collaboration graph
[legend]

Public Member Functions

 SDDSParser ()
 
 SDDSParser (const std::string &input)
 
void setInput (const std::string &input)
 
file run ()
 
const file & getData () const
 
const ast::columnData_t & getColumnData (const std::string &columnName) const
 
ast::dataType getColumnType (const std::string &col_name) const
 
template<typename T >
void getValue (int t, const std::string &column_name, T &nval)
 
template<typename T >
void getInterpolatedValue (const std::string &ref_name, double ref_val, const std::string &col_name, T &nval)
 
template<typename T >
void getInterpolatedValue (double spos, const std::string &col_name, T &nval)
 
template<typename T >
void getParameterValue (const std::string &parameter_name, T &nval)
 
template<typename T >
T getVariantValue (const ast::variant_t &val, ast::dataType type) const
 Convert value from variant (only numeric types) to a value of type T.
 

Private Member Functions

std::string readFile ()
 
int getColumnIndex (const std::string &col_name) const
 

Static Private Member Functions

static std::string normalizeKey (std::string_view value)
 

Private Attributes

std::string sddsFileName_m
 
std::unordered_map< std::string, std::size_t > paramNameToID_m
 mapping from parameter name to offset in params_m
 
std::unordered_map< std::string, std::size_t > columnNameToID_m
 mapping from column name to ID in columns_m
 
SDDS::file sddsData_m
 

Detailed Description

Definition at line 35 of file SDDSParser.h.

Constructor & Destructor Documentation

◆ SDDSParser() [1/2]

SDDS::SDDSParser::SDDSParser ( )

Definition at line 29 of file SDDSParser.cpp.

◆ SDDSParser() [2/2]

SDDS::SDDSParser::SDDSParser ( const std::string &  input)

Definition at line 33 of file SDDSParser.cpp.

Member Function Documentation

◆ getColumnData()

const SDDS::ast::columnData_t & SDDS::SDDSParser::getColumnData ( const std::string &  columnName) const

Definition at line 147 of file SDDSParser.cpp.

Referenced by OpalSimulation::getData().

◆ getColumnIndex()

int SDDS::SDDSParser::getColumnIndex ( const std::string &  col_name) const
private

Definition at line 152 of file SDDSParser.cpp.

Referenced by getColumnType(), getInterpolatedValue(), and getValue().

◆ getColumnType()

ast::dataType SDDS::SDDSParser::getColumnType ( const std::string &  col_name) const
inline

Definition at line 57 of file SDDSParser.h.

References getColumnIndex(), SDDS::file::sddsColumns_m, and sddsData_m.

Referenced by OpalSimulation::getData(), getInterpolatedValue(), and getValue().

Here is the call graph for this function:

◆ getData()

const file & SDDS::SDDSParser::getData ( ) const
inline

Definition at line 235 of file SDDSParser.h.

References sddsData_m.

◆ getInterpolatedValue() [1/2]

template<typename T >
void SDDS::SDDSParser::getInterpolatedValue ( const std::string &  ref_name,
double  ref_val,
const std::string &  col_name,
T &  nval 
)
inline

Converts the string value of a parameter to a value of type T.

Parameters
ref_namereference quantity (e.g. spos)
ref_valinterpolate value of reference quantity (e.g. spos)
col_nameparameter name
nvalstore result of type T in nval

Definition at line 102 of file SDDSParser.h.

References getColumnIndex(), getColumnType(), SDDS::file::sddsColumns_m, and sddsData_m.

Referenced by getInterpolatedValue().

Here is the call graph for this function:

◆ getInterpolatedValue() [2/2]

template<typename T >
void SDDS::SDDSParser::getInterpolatedValue ( double  spos,
const std::string &  col_name,
T &  nval 
)
inline

Converts the string value of a parameter at a position spos to a value of type T.

Parameters
sposinterpolate value at spos
col_nameparameter name
nvalstore result of type T in nval

Definition at line 167 of file SDDSParser.h.

References getInterpolatedValue().

Here is the call graph for this function:

◆ getParameterValue()

template<typename T >
void SDDS::SDDSParser::getParameterValue ( const std::string &  parameter_name,
T &  nval 
)
inline

Converts the string value of a parameter to a value of type T.

Parameters
parameter_nameparameter name
nvalstore result of type T in nval

Definition at line 179 of file SDDSParser.h.

References normalizeKey(), paramNameToID_m, sddsData_m, and SDDS::file::sddsParameters_m.

Referenced by SDDSWriter::replaceVersionString().

Here is the call graph for this function:

◆ getValue()

template<typename T >
void SDDS::SDDSParser::getValue ( int  t,
const std::string &  column_name,
T &  nval 
)
inline

Converts the string value of a parameter at timestep t to a value of type T.

Parameters
ttimestep (beginning at 1, -1 means last)
column_nameparameter name
nvalstore result of type T in nval

Definition at line 71 of file SDDSParser.h.

References getColumnIndex(), getColumnType(), SDDS::file::sddsColumns_m, and sddsData_m.

Referenced by SDDSWriter::getLastValue().

Here is the call graph for this function:

◆ getVariantValue()

template<typename T >
T SDDS::SDDSParser::getVariantValue ( const ast::variant_t &  val,
ast::dataType  type 
) const
inline

Convert value from variant (only numeric types) to a value of type T.

Definition at line 193 of file SDDSParser.h.

References SDDS::ast::DOUBLE, SDDS::ast::FLOAT, SDDS::ast::LONG, and SDDS::ast::SHORT.

Referenced by OpalSimulation::getData().

◆ normalizeKey()

std::string SDDS::SDDSParser::normalizeKey ( std::string_view  value)
staticprivate

Definition at line 162 of file SDDSParser.cpp.

Referenced by getParameterValue().

◆ readFile()

std::string SDDS::SDDSParser::readFile ( )
private

Definition at line 119 of file SDDSParser.cpp.

◆ run()

SDDS::file SDDS::SDDSParser::run ( )

◆ setInput()

void SDDS::SDDSParser::setInput ( const std::string &  input)

Definition at line 37 of file SDDSParser.cpp.

Member Data Documentation

◆ columnNameToID_m

std::unordered_map<std::string, std::size_t> SDDS::SDDSParser::columnNameToID_m
private

mapping from column name to ID in columns_m

Definition at line 44 of file SDDSParser.h.

◆ paramNameToID_m

std::unordered_map<std::string, std::size_t> SDDS::SDDSParser::paramNameToID_m
private

mapping from parameter name to offset in params_m

Definition at line 42 of file SDDSParser.h.

Referenced by getParameterValue().

◆ sddsData_m

SDDS::file SDDS::SDDSParser::sddsData_m
private

◆ sddsFileName_m

std::string SDDS::SDDSParser::sddsFileName_m
private

Definition at line 39 of file SDDSParser.h.


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