1#ifndef FIRE_IO_H5_PARAMETERSTORAGE_H
2#define FIRE_IO_H5_PARAMETERSTORAGE_H
5#include <boost/core/demangle.hpp>
11#include "fire/io/Data.h"
12#include "fire/io/Reader.h"
13#include "fire/exception/Exception.h"
59 template <
typename ParameterType>
62 return std::get<ParameterType>(
parameters_.at(name));
63 }
catch (
const std::bad_variant_access&) {
65 "Parameter named " + name +
" is not type " +
66 boost::core::demangle(
typeid(ParameterType).name()));
68 throw Exception(
"NotFound",
"Parameter named " + name +
" not found.");
94 template <
typename ParameterType>
97 std::is_same_v<ParameterType, int> ||
98 std::is_same_v<ParameterType, float> ||
99 std::is_same_v<ParameterType, std::string>,
100 "Parameters are only allowed to be float, int, or std::string.");
186 throw Exception(
"BadCode",
"This function should never be called.");
224 template <
typename ParameterType>
226 parameters_[name] = std::make_unique<Data<ParameterType>>(
227 this->
path_ +
"/" + name,
229 std::get_if<ParameterType>(&(this->
handle_->parameters_[name])));
Standard base exception class with some useful output information.
Definition: Exception.h:18
Type-specific base class to hold common data methods.
Definition: AbstractData.h:96
DataType * handle_
handle on current object in memory
Definition: AbstractData.h:237
std::string path_
path of data set
Definition: AbstractData.h:82
std::unordered_map< std::string, std::unique_ptr< BaseData > > parameters_
the dynamic parameter listing (parallel to parameters_ member variable)
Definition: ParameterStorage.h:234
void attach(const std::string &name)
Attach the input parameter name as a new dataset in our own parameter map using the entry in the hand...
Definition: ParameterStorage.h:225
Reader * input_file_
the input file we are reading from
Definition: ParameterStorage.h:236
General data set.
Definition: Data.h:90
void save(Writer &f) final override
pure virtual method for saving data
Definition: Data.h:166
Reader * input_file_
pointer to the input file (if there is one)
Definition: Data.h:236
void load(h5::Reader &f) final override
Loading this dataset from the file involves simply loading all of the members of the data type.
Definition: Data.h:135
Data(const std::string &path, Reader *input_file=nullptr, DataType *handle=nullptr)
Attach ourselves to the input type after construction.
Definition: Data.h:116
void structure(Writer &f) final override
pure virtual method for saving structure
Definition: Data.h:170
Provides dynamic parameter storage by interfacing between a map to variants storing parameters and a ...
Definition: ParameterStorage.h:40
std::unordered_map< std::string, std::variant< int, float, std::string > > parameters_
three types of parameters are allowed: int, float, string
Definition: ParameterStorage.h:123
void clear()
clear the parameters
Definition: ParameterStorage.cxx:6
void set(const std::string &name, const ParameterType &val)
Set a parameter to be a specific value.
Definition: ParameterStorage.h:95
const ParameterType & get(const std::string &name) const
Get a parameter corresponding to the input name.
Definition: ParameterStorage.h:60
Prototype for reading files within fire.
Definition: Reader.h:29
Write the fire DataSets into a deterministic structure in the output HDF5 data file.
Definition: Writer.h:19
Reading a file generated by fire.
Definition: Reader.h:22
Reading ROOT files into our data structures.
Definition: Reader.h:29
Geant4 does a GLOBAL definition of the keyword TRUE.
Definition: AbstractData.h:11