File GenericParameters.h

namespace sio

Typedefs

using version_type = uint32_t
namespace podio

Typedefs

using SupportedGenericDataTypes = std::tuple<int, float, std::string, double>

The types which are supported in the GenericParameters.

template<typename T>
using EnableIfValidGenericDataType = typename std::enable_if_t<isSupportedGenericDataType<T>>

Alias template to be used for enabling / disabling template overloads that should only be present for actually supported data types.

template<typename T>
using GenericDataReturnType = typename detail::GenericDataReturnTypeHelper<T>::type

Alias template for determining the appropriate return type for the passed in type.

Variables

template<typename T>
static constexpr bool isSupportedGenericDataType = detail::isAnyOrVectorOf<T, SupportedGenericDataTypes>

Static bool for determining if a type T is a supported GenericParameters type.

class GenericParameters
#include <podio/GenericParameters.h>

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.

Private Types

using MutexPtr = std::unique_ptr<std::mutex>

Private Functions

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

Get a reference to the internal map for a given type (necessary for SIO)

template<typename T>
inline std::mutex &getMutex() const

Get the mutex that guards the map for the given type.

Private Members

MapType<int> _intMap = {}

The map storing the integer values.

mutable MutexPtr m_intMtx = {nullptr}

The mutex guarding the integer map.

MapType<float> _floatMap = {}

The map storing the float values.

mutable MutexPtr m_floatMtx = {nullptr}

The mutex guarding the float map.

MapType<std::string> _stringMap = {}

The map storing the string values.

mutable MutexPtr m_stringMtx = {nullptr}

The mutex guarding the string map.

MapType<double> _doubleMap = {}

The map storing the double values.

mutable MutexPtr m_doubleMtx = {nullptr}

The mutex guarding the double map.

Friends

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