Project
Loading...
Searching...
No Matches
CallbackService.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_CALLBACKSERVICE_H_
12#define O2_FRAMEWORK_CALLBACKSERVICE_H_
13
17#include "ServiceRegistry.h"
18
19#include <fairmq/FwdDecls.h>
20
21namespace o2::header
22{
23struct DataHeader;
24}
25
26namespace o2::framework
27{
28
30struct EndOfStreamContext;
31
32// A service that data processors can register callback functions invoked by the
33// framework at defined steps in the process flow
35{
36 public:
89
90 using StartCallback = std::function<void()>;
91 using StopCallback = std::function<void()>;
92 using ResetCallback = std::function<void()>;
93 using IdleCallback = std::function<void()>;
94 using ClockTickCallback = std::function<void()>;
97 using RegionInfoCallback = std::function<void(fair::mq::RegionInfo const&)>;
99 using PreProcessingCallback = std::function<void(ServiceRegistryRef, int)>;
100 using FinaliseOutputsCallback = std::function<void(ServiceRegistryRef, int)>;
101 using PostProcessingCallback = std::function<void(ServiceRegistryRef, int)>;
102 using CCDBDeserializedCallback = std::function<void(ConcreteDataMatcher&, void*)>;
103 using DomainInfoUpdatedCallback = std::function<void(ServiceRegistryRef, size_t timeslice, ChannelIndex index)>;
104 using DeviceStateChangedCallback = std::function<void(ServiceRegistryRef, int newState)>;
106
124 >; //
125
126 template <Id ID, typename U>
127 void set(U&& cb)
128 {
129 mCallbacks.set<ID>(std::forward<U>(cb));
130 }
131
132 // execute callback for specified processing step with argument pack
133 template <Id ID, typename... TArgs>
134 auto call(TArgs&&... args)
135 {
136 mCallbacks.call<ID>(std::forward<TArgs>(args)...);
137 }
138
139 private:
140 Callbacks mCallbacks;
141};
142
143} // namespace o2::framework
144#endif // O2_FRAMEWORK_CALLBACKSERVICE_H_
std::function< void(EndOfStreamContext &)> EndOfStreamCallback
std::function< void()> ResetCallback
std::function< void(ServiceRegistryRef, int)> PostProcessingCallback
std::function< void(ServiceRegistryRef, int)> FinaliseOutputsCallback
auto call(TArgs &&... args)
std::function< void(ServiceRegistryRef, size_t timeslice, ChannelIndex index)> DomainInfoUpdatedCallback
std::function< void()> IdleCallback
std::function< void()> ClockTickCallback
std::function< void(ConcreteDataMatcher &, void *)> CCDBDeserializedCallback
std::function< void(fair::mq::RegionInfo const &)> RegionInfoCallback
std::function< void()> StartCallback
std::function< void(o2::header::DataHeader &, DataProcessingHeader &)> NewTimesliceCallback
std::function< void(ServiceRegistryRef, int newState)> DeviceStateChangedCallback
static constexpr ServiceKind service_kind
std::function< void(ServiceRegistryRef, int)> PreProcessingCallback
std::function< void()> StopCallback
std::function< void(ServiceRegistryRef)> ExitRequestedCallback
std::function< void(ServiceRegistryRef)> DataConsumedCallback
Id
the defined processing steps at which a callback can be invoked
@ PreProcessing
Invoked before the processing callback.
@ ExitRequested
Invoked when the device was requested to stop.
@ DomainInfoUpdated
Invoked when new domain info is available.
@ DeviceStateChanged
Invoked the device undergoes a state change.
@ PostProcessing
Invoked after the processing callback,.
CallbackRegistry< Id, RegistryPair< Id, Id::Start, StartCallback >, RegistryPair< Id, Id::Stop, StopCallback >, RegistryPair< Id, Id::Reset, ResetCallback >, RegistryPair< Id, Id::Idle, IdleCallback >, RegistryPair< Id, Id::ClockTick, ClockTickCallback >, RegistryPair< Id, Id::DataConsumed, DataConsumedCallback >, RegistryPair< Id, Id::EndOfStream, EndOfStreamCallback >, RegistryPair< Id, Id::RegionInfoCallback, RegionInfoCallback >, RegistryPair< Id, Id::NewTimeslice, NewTimesliceCallback >, RegistryPair< Id, Id::PreProcessing, PreProcessingCallback >, RegistryPair< Id, Id::FinaliseOutputs, FinaliseOutputsCallback >, RegistryPair< Id, Id::PostProcessing, PostProcessingCallback >, RegistryPair< Id, Id::CCDBDeserialised, CCDBDeserializedCallback >, RegistryPair< Id, Id::DomainInfoUpdated, DomainInfoUpdatedCallback >, RegistryPair< Id, Id::DeviceStateChanged, DeviceStateChangedCallback >, RegistryPair< Id, Id::ExitRequested, ExitRequestedCallback > > Callbacks
GLuint index
Definition glcorearb.h:781
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
ServiceKind
The kind of service we are asking for.
O2 data header classes and API, v0.1.
Definition DetID.h:49
the main header struct
Definition DataHeader.h:618