The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::TestSuite::Conditions::details::ConditionsStore Class Reference

Example class to implement an actual backend for Gaudi::TestSuite::Conditions::ConditionAccessorHolder. More...

#include </builds/gaudi/Gaudi/GaudiTestSuite/include/Gaudi/TestSuite/Conditions/ConditionAccessorHolder.h>

Collaboration diagram for Gaudi::TestSuite::Conditions::details::ConditionsStore:

Public Types

using ConditionContext = int
using ConditionKey = std::string

Public Member Functions

void declareKey (const ConditionKey &key)
const ConditionContext & getConditionContext (const EventContext &ctx) const
template<typename T>
const T & getCondition (const ConditionKey &key, const ConditionContext &ctx) const

Static Public Member Functions

static ConditionsStore & instance ()

Private Types

using IOVSlot = std::map<ConditionKey, std::any>
using IOVSlots = std::map<ConditionContext, IOVSlot>

Private Member Functions

 ConditionsStore ()=default
const std::any * getConditionAny (const ConditionKey &key, const ConditionContext &ctx) const

Private Attributes

std::mutex m_storageMtx
IOVSlots m_storage
std::set< ConditionKey > m_requestedKeys

Detailed Description

Example class to implement an actual backend for Gaudi::TestSuite::Conditions::ConditionAccessorHolder.

Definition at line 24 of file ConditionAccessorHolder.h.

Member Typedef Documentation

◆ ConditionContext

◆ ConditionKey

◆ IOVSlot

Definition at line 44 of file ConditionAccessorHolder.h.

◆ IOVSlots

Constructor & Destructor Documentation

◆ ConditionsStore()

Gaudi::TestSuite::Conditions::details::ConditionsStore::ConditionsStore ( )
privatedefault

Member Function Documentation

◆ declareKey()

void Gaudi::TestSuite::Conditions::details::ConditionsStore::declareKey ( const ConditionKey & key)

Definition at line 20 of file Backend.cpp.

20 {
21 if ( std::get<1>( m_requestedKeys.emplace( key ) ) ) {
22 std::cout << "ConditionsStore: requested condition " << key << '\n';
23 }
24 }

◆ getCondition()

template<typename T>
const T & Gaudi::TestSuite::Conditions::details::ConditionsStore::getCondition ( const ConditionKey & key,
const ConditionContext & ctx ) const
inline

Definition at line 36 of file ConditionAccessorHolder.h.

36 {
37 return *std::any_cast<T>( getConditionAny( key, ctx ) );
38 }
const std::any * getConditionAny(const ConditionKey &key, const ConditionContext &ctx) const
Definition Backend.cpp:33

◆ getConditionAny()

const std::any * Gaudi::TestSuite::Conditions::details::ConditionsStore::getConditionAny ( const ConditionKey & key,
const ConditionContext & ctx ) const
private

Definition at line 33 of file Backend.cpp.

33 {
34 auto lg = std::scoped_lock{ m_storageMtx };
35 if ( m_storage.find( ctx ) == end( m_storage ) ) {
36 std::cout << "ConditionsStore: first access to store " << ctx << '\n';
37 auto& store = m_storage[ctx];
38 for ( const auto& key : m_requestedKeys ) {
39 std::cout << "ConditionsStore: prepare condition " << key << '\n';
40 store.emplace( key, ctx );
41 }
42 } else {
43 std::cout << "ConditionsStore: using existing store " << ctx << '\n';
44 }
45 return &m_storage[ctx][key];
46 }

◆ getConditionContext()

const ConditionsStore::ConditionContext & Gaudi::TestSuite::Conditions::details::ConditionsStore::getConditionContext ( const EventContext & ctx) const

Definition at line 26 of file Backend.cpp.

26 {
27 static ConditionContext current_iov = 0;
28
29 current_iov = ctx.evt() % 2;
30 return current_iov;
31 }

◆ instance()

ConditionsStore & Gaudi::TestSuite::Conditions::details::ConditionsStore::instance ( )
static

Definition at line 15 of file Backend.cpp.

15 {
16 static ConditionsStore store{};
17 return store;
18 }

Member Data Documentation

◆ m_requestedKeys

std::set<ConditionKey> Gaudi::TestSuite::Conditions::details::ConditionsStore::m_requestedKeys
private

Definition at line 49 of file ConditionAccessorHolder.h.

◆ m_storage

IOVSlots Gaudi::TestSuite::Conditions::details::ConditionsStore::m_storage
mutableprivate

Definition at line 48 of file ConditionAccessorHolder.h.

◆ m_storageMtx

std::mutex Gaudi::TestSuite::Conditions::details::ConditionsStore::m_storageMtx
mutableprivate

Definition at line 47 of file ConditionAccessorHolder.h.


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