ATLAS Offline Software
Loading...
Searching...
No Matches
ISkipEventIdxSvc.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2/*
3 * Copyright (C) 2023 CERN for the benefit of the ATLAS collaboration.
4 */
5#ifndef PILEUPMT_ISKIPEVENTIDXSVC_H
6#define PILEUPMT_ISKIPEVENTIDXSVC_H
7
8#include <GaudiKernel/IService.h>
9
10#include <cstdint>
11#include <format>
12
13class ISkipEventIdxSvc : virtual public IService {
14 public:
16 struct EvtId {
17 std::uint32_t runNum = 0;
18 std::uint32_t lbNum = 0;
19 std::uint64_t evtNum = 0;
20 std::uint64_t evtIdx = 0;
21 };
22
23 using EvtIter = std::vector<EvtId>::const_iterator;
24
25 template <
26 typename Fn,
27 std::enable_if_t<std::is_invocable_r_v<StatusCode, Fn, EvtIter, EvtIter>>>
28 StatusCode registerCallback(Fn&& callback) {
29 return this->registerCallback(
30 std::function<StatusCode(EvtIter, EvtIter)>(callback));
31 }
32 virtual StatusCode registerCallback(
33 std::function<StatusCode(EvtIter, EvtIter)>&& callback) = 0;
34};
35
36template <>
37struct std::formatter<ISkipEventIdxSvc::EvtId> : formatter<string_view> {
38 template <typename FormatContext>
39 auto format(const ISkipEventIdxSvc::EvtId& evtId, FormatContext& ctx) {
40 std::format_to(ctx.out, "[Run: {}, LB: {}, Evt: {} ({})]", evtId.runNum,
41 evtId.lbNum, evtId.evtNum, evtId.evtIdx);
42 return ctx.out;
43 }
44};
45#endif // PILEUPMT_ISKIPEVENTIDXSVC_H
virtual StatusCode registerCallback(std::function< StatusCode(EvtIter, EvtIter)> &&callback)=0
DeclareInterfaceID(ISkipEventIdxSvc, 1, 0)
std::vector< EvtId >::const_iterator EvtIter
StatusCode registerCallback(Fn &&callback)
auto format(const ISkipEventIdxSvc::EvtId &evtId, FormatContext &ctx)