Project
Loading...
Searching...
No Matches
o2::utils::RootSerializableKeyValueStore Class Reference

#include <RootSerializableKeyValueStore.h>

Classes

struct  SerializedInfo
 Structure encapsulating the stored information: raw buffers and attached type information (combination of type_index_hash and TClass information) More...
 

Public Types

enum class  GetState { kOK = 0 , kNOSUCHKEY = 1 , kWRONGTYPE = 2 , kNOTCLASS = 3 }
 

Public Member Functions

 RootSerializableKeyValueStore ()=default
 
template<typename T >
void put (std::string const &key, T const &value)
 
template<typename T >
const T * get (std::string const &key) const
 returns object pointer for this key or nullptr if error or does not exist.
 
template<typename T >
const T * get (std::string const &key, GetState &state) const
 returns object pointer for this key or nullptr if error or does not exist; state is set with meaningful error code
 
template<typename T >
const T & getRef (std::string const &key, GetState &state) const
 
bool has (std::string const &key) const
 checks if a key exists
 
void clear ()
 clear the store
 
void print (bool includetypeinfo=false) const
 print list of keys, values (and optionally type information)
 
void copyFrom (RootSerializableKeyValueStore const &other)
 resets store to the store of another object
 

Static Public Member Functions

static const chargetStateString (GetState state)
 

Detailed Description

A ROOT serializable container mapping a key (string) to an object of arbitrary type.

The container allows to group objects in heterogeneous type in a key-value container. The container can be ROOT serialized which adds on-top of existing solutions such as boost::property_tree. This may be useful in various circumenstances, for instance to assemble various CCDB objects into a single aggregate to reduce the number of CCDB files/entries.

Definition at line 37 of file RootSerializableKeyValueStore.h.

Member Enumeration Documentation

◆ GetState

Enumerator
kOK 
kNOSUCHKEY 
kWRONGTYPE 
kNOTCLASS 

Definition at line 81 of file RootSerializableKeyValueStore.h.

Constructor & Destructor Documentation

◆ RootSerializableKeyValueStore()

o2::utils::RootSerializableKeyValueStore::RootSerializableKeyValueStore ( )
default

Member Function Documentation

◆ clear()

void o2::utils::RootSerializableKeyValueStore::clear ( )
inline

clear the store

Definition at line 150 of file RootSerializableKeyValueStore.h.

◆ copyFrom()

void o2::utils::RootSerializableKeyValueStore::copyFrom ( RootSerializableKeyValueStore const &  other)
inline

resets store to the store of another object

Definition at line 159 of file RootSerializableKeyValueStore.h.

◆ get() [1/2]

template<typename T >
const T * o2::utils::RootSerializableKeyValueStore::get ( std::string const &  key) const
inline

returns object pointer for this key or nullptr if error or does not exist.

Definition at line 115 of file RootSerializableKeyValueStore.h.

◆ get() [2/2]

template<typename T >
const T * o2::utils::RootSerializableKeyValueStore::get ( std::string const &  key,
GetState state 
) const
inline

returns object pointer for this key or nullptr if error or does not exist; state is set with meaningful error code

Definition at line 123 of file RootSerializableKeyValueStore.h.

◆ getRef()

template<typename T >
const T & o2::utils::RootSerializableKeyValueStore::getRef ( std::string const &  key,
GetState state 
) const
inline

get interface returning a const reference instead of pointer; Error handling/detection is done via the state argument; Beware: In case of errors, a default object is returned.

Definition at line 131 of file RootSerializableKeyValueStore.h.

◆ getStateString()

static const char * o2::utils::RootSerializableKeyValueStore::getStateString ( GetState  state)
inlinestatic

Definition at line 96 of file RootSerializableKeyValueStore.h.

◆ has()

bool o2::utils::RootSerializableKeyValueStore::has ( std::string const &  key) const
inline

checks if a key exists

Definition at line 144 of file RootSerializableKeyValueStore.h.

◆ print()

void RootSerializableKeyValueStore::print ( bool  includetypeinfo = false) const

print list of keys, values (and optionally type information)

Definition at line 28 of file RootSerializableKeyValueStore.cxx.

◆ put()

template<typename T >
void o2::utils::RootSerializableKeyValueStore::put ( std::string const &  key,
T const &  value 
)
inline

Putting a value (and overrides previous entries) T needs to be trivial non-pointer type or a type having a ROOT TClass instance

Definition at line 106 of file RootSerializableKeyValueStore.h.


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