File GenericParameters.h
-
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.
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)
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
Friends
-
friend void writeGenericParameters(sio::write_device &device, const GenericParameters ¶meters)
-
friend void readGenericParameters(sio::read_device &device, GenericParameters ¶meters, sio::version_type version)
-
using SupportedGenericDataTypes = std::tuple<int, float, std::string, double>