Class podio::GenericParameters

class GenericParameters

GenericParameters objects allow to store generic named parameters of type int, float and string or vectors of these types.

They can be used to store (user) meta data that is run, event or collection dependent. (based on lcio::LCParameters)

Author

F. Gaede, DESY

Date

Apr 2020

Public Types

template<typename T>
using MapType = std::map<std::string, std::vector<T>>

Public Functions

GenericParameters()
GenericParameters(const GenericParameters&)

GenericParameters are copyable NOTE: This is currently mainly done to keep the ROOT I/O happy, because that needs a copy constructor.

GenericParameters &operator=(const GenericParameters&) = delete
GenericParameters(GenericParameters&&) = default

GenericParameters are default moveable.

GenericParameters &operator=(GenericParameters&&) = default
~GenericParameters() = default
template<typename T, typename = EnableIfValidGenericDataType<T>>
GenericDataReturnType<T> getValue(const std::string&) const

Get the value that is stored under the given key, by const reference or by value depending on the desired type.

template<typename T, typename = EnableIfValidGenericDataType<T>>
void setValue(const std::string &key, T value)

Store (a copy of) the passed value under the given key.

inline void setValue(const std::string &key, std::string value)

Overload for catching const char* setting for string values.

inline void setValue(const std::string &key, std::vector<std::string> values)

Overload for catching initializer list setting of string vector values.

template<typename T, typename = std::enable_if_t<detail::isInTuple<T, SupportedGenericDataTypes>>>
inline void setValue(const std::string &key, std::initializer_list<T> &&values)

Overload for catching initializer list setting for vector values.

template<typename T, typename = EnableIfValidGenericDataType<T>>
size_t getN(const std::string &key) const

Get the number of elements stored under the given key for a type.

template<typename T, typename = EnableIfValidGenericDataType<T>>
std::vector<std::string> getKeys() const

Get all available keys for a given type.

inline void clear()

erase all elements

void print(std::ostream &os = std::cout, bool flush = true)
inline bool empty() const

Check if no parameter is stored (i.e. if all internal maps are empty)

template<typename T>
inline const MapType<detail::GetVectorType<T>> &getMap() const

Get a reference to the internal map for a given type.

Friends

friend void writeGenericParameters(sio::write_device &device, const GenericParameters &parameters)
friend void readGenericParameters(sio::read_device &device, GenericParameters &parameters, sio::version_type version)