Project
Loading...
Searching...
No Matches
CommonMessageBackendsHelpers.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_COMMONMESSAGEBACKENDSHELPERS_H_
12#define O2_FRAMEWORK_COMMONMESSAGEBACKENDSHELPERS_H_
13
21#include "Framework/Tracing.h"
22
23#include <fairmq/ProgOptions.h>
24
25namespace o2::framework
26{
27
28template <typename T>
31 {
32 return [](ServiceRegistryRef services, DeviceState&, fair::mq::ProgOptions& options) {
33 auto& proxy = services.get<FairMQDeviceProxy>();
34 return ServiceHandle{TypeIdHelpers::uniqueId<T>(), new T(proxy), ServiceKind::Stream};
35 };
36 }
37
39 {
40 return [](ProcessingContext& ctx, void* service) {
41 T* context = reinterpret_cast<T*>(service);
42 DataProcessor::doSend(ctx.services().get<DataSender>(), *context, ctx.services());
43 };
44 }
45
47 {
48 return [](ProcessingContext&, void* service) {
49 T* context = reinterpret_cast<T*>(service);
50 context->clear();
51 };
52 }
53
55 {
56 return [](EndOfStreamContext&, void* service) {
57 T* context = reinterpret_cast<T*>(service);
58 context->clear();
59 };
60 }
61
63 {
64 return [](EndOfStreamContext& ctx, void* service) {
65 T* context = reinterpret_cast<T*>(service);
66 DataProcessor::doSend(ctx.services().get<DataSender>(), *context, ctx.services());
67 };
68 }
69};
70} // namespace o2::framework
71
72#endif // O2_FRAMEWORK_COMMONMESSAGEBACKENDSHELPERS_H_
Allow injecting policies on send.
Definition DataSender.h:34
ServiceRegistryRef services()
The services registry associated with this processing context.
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
ServiceHandle(*)(ServiceRegistryRef, DeviceState &, fair::mq::ProgOptions &) ServiceInit
A callback to create a given Service.
Definition ServiceSpec.h:48
void(*)(EndOfStreamContext &, void *) ServiceEOSCallback
A callback which is executed before the end of stream loop.
Definition ServiceSpec.h:68
void(*)(ProcessingContext &, void *) ServiceProcessingCallback
A callback which is executed before each processing loop.
Definition ServiceSpec.h:62
static void doSend(DataSender &, MessageContext &, ServiceRegistryRef)
Running state information of a given device.
Definition DeviceState.h:34