Project
Loading...
Searching...
No Matches
ContextHelpers.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_CONTEXTHELPERS_H_
12#define O2_FRAMEWORK_CONTEXTHELPERS_H_
13
17
18namespace o2::framework
19{
21 static void bindStreamService(DataProcessorContext& dpContext, StreamContext& stream, ServiceSpec const& spec, void* service);
22 static void bindProcessorService(DataProcessorContext& dpContext, ServiceSpec const& spec, void* service);
23};
24
25void ContextHelpers::bindStreamService(DataProcessorContext& dpContext, StreamContext& context, ServiceSpec const& spec, void* service)
26{
27 assert(spec.preDangling == nullptr);
28 assert(spec.postDangling == nullptr);
29 assert(spec.postDispatching == nullptr);
30 assert(spec.postForwarding == nullptr);
31 assert(spec.stop == nullptr);
32 assert(spec.exit == nullptr);
33 assert(spec.domainInfoUpdated == nullptr);
34 assert(spec.preSendingMessages == nullptr);
35 assert(spec.postRenderGUI == nullptr);
36 // Notice that this will mean that stream services will execute the start
37 // callback once per stream, not once per dataprocessor.
38 if (spec.start) {
39 context.preStartStreamHandles.push_back(ServiceStartStreamHandle{spec, spec.start, service});
40 }
41 if (spec.preProcessing) {
42 context.preProcessingHandles.push_back(ServiceProcessingHandle{spec, spec.preProcessing, service});
43 }
44 if (spec.finaliseOutputs) {
45 context.finaliseOutputsHandles.push_back(ServiceProcessingHandle{spec, spec.finaliseOutputs, service});
46 }
47 if (spec.postProcessing) {
48 context.postProcessingHandles.push_back(ServiceProcessingHandle{spec, spec.postProcessing, service});
49 }
50 // We need to call the preEOS also on a per stream basis, not only on a per
51 // data processor basis.
52 if (spec.preEOS) {
53 dpContext.preEOSHandles.push_back(ServiceEOSHandle{spec, spec.preEOS, service});
54 }
55 if (spec.postEOS) {
56 dpContext.postEOSHandles.push_back(ServiceEOSHandle{spec, spec.postEOS, service});
57 }
58}
59
60void ContextHelpers::bindProcessorService(DataProcessorContext& dataProcessorContext, ServiceSpec const& spec, void* service)
61{
62 if (spec.preProcessing) {
63 dataProcessorContext.preProcessingHandlers.push_back(ServiceProcessingHandle{spec, spec.preProcessing, service});
64 }
65 if (spec.finaliseOutputs) {
66 dataProcessorContext.finaliseOutputsHandles.push_back(ServiceProcessingHandle{spec, spec.finaliseOutputs, service});
67 }
68 if (spec.postProcessing) {
69 dataProcessorContext.postProcessingHandlers.push_back(ServiceProcessingHandle{spec, spec.postProcessing, service});
70 }
71 if (spec.preDangling) {
72 dataProcessorContext.preDanglingHandles.push_back(ServiceDanglingHandle{spec, spec.preDangling, service});
73 }
74 if (spec.postDangling) {
75 dataProcessorContext.postDanglingHandles.push_back(ServiceDanglingHandle{spec, spec.postDangling, service});
76 }
77 if (spec.preEOS) {
78 dataProcessorContext.preEOSHandles.push_back(ServiceEOSHandle{spec, spec.preEOS, service});
79 }
80 if (spec.postEOS) {
81 dataProcessorContext.postEOSHandles.push_back(ServiceEOSHandle{spec, spec.postEOS, service});
82 }
83 if (spec.postDispatching) {
84 dataProcessorContext.postDispatchingHandles.push_back(ServiceDispatchingHandle{spec, spec.postDispatching, service});
85 }
86 if (spec.postForwarding) {
87 dataProcessorContext.postForwardingHandles.push_back(ServiceForwardingHandle{spec, spec.postForwarding, service});
88 }
89 if (spec.start) {
90 dataProcessorContext.preStartHandles.push_back(ServiceStartHandle{spec, spec.start, service});
91 }
92 if (spec.stop) {
93 dataProcessorContext.postStopHandles.push_back(ServiceStopHandle{spec, spec.stop, service});
94 }
95 if (spec.exit) {
96 dataProcessorContext.preExitHandles.push_back(ServiceExitHandle{spec, spec.exit, service});
97 }
98 if (spec.domainInfoUpdated) {
99 dataProcessorContext.domainInfoHandles.push_back(ServiceDomainInfoHandle{spec, spec.domainInfoUpdated, service});
100 }
101 if (spec.preSendingMessages) {
102 dataProcessorContext.preSendingMessagesHandles.push_back(ServicePreSendingMessagesHandle{spec, spec.preSendingMessages, service});
103 }
104 if (spec.preLoop) {
105 dataProcessorContext.preLoopHandles.push_back(ServicePreLoopHandle{spec, spec.preLoop, service});
106 }
107}
108
109} // namespace o2::framework
110#endif // O2_FRAMEWORK_CONTEXTHELPERS_H_
GLuint GLuint stream
Definition glcorearb.h:1806
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
static void bindProcessorService(DataProcessorContext &dpContext, ServiceSpec const &spec, void *service)
static void bindStreamService(DataProcessorContext &dpContext, StreamContext &stream, ServiceSpec const &spec, void *service)
std::vector< ServicePreSendingMessagesHandle > preSendingMessagesHandles
Callbacks for services to be executed before sending messages.
std::vector< ServiceDanglingHandle > preDanglingHandles
Callbacks for services to be executed before every dangling check.
std::vector< ServiceEOSHandle > postEOSHandles
Callbacks for services to be executed after every EOS user callback invokation.
std::vector< ServiceEOSHandle > preEOSHandles
Callbacks for services to be executed before every EOS user callback invokation.
std::vector< ServiceDomainInfoHandle > domainInfoHandles
Callbacks for services to be executed on exit.
std::vector< ServiceStartHandle > preStartHandles
Callbacks for services to be executed before Start.
std::vector< ServicePreLoopHandle > preLoopHandles
Callbacks for services to be executed before we enter the event loop.
std::vector< ServiceProcessingHandle > postProcessingHandlers
std::vector< ServiceForwardingHandle > postForwardingHandles
Callbacks for services to be executed after every dispatching.
std::vector< ServiceDispatchingHandle > postDispatchingHandles
Callbacks for services to be executed after every dispatching.
std::vector< ServiceExitHandle > preExitHandles
Callbacks for services to be executed on exit.
std::vector< ServiceStopHandle > postStopHandles
Callbacks for services to be executed on the Stop transition.
std::vector< ServiceProcessingHandle > finaliseOutputsHandles
std::vector< ServiceDanglingHandle > postDanglingHandles
Callbacks for services to be executed after every dangling check.
std::vector< ServiceProcessingHandle > preProcessingHandlers
ServiceDanglingCallback postDangling
Callback executed after the dangling inputs loop.
ServiceExitCallback exit
Callback invoked on exit.
ServiceProcessingCallback preProcessing
Callback executed before actual processing happens.
ServicePreLoop preLoop
Callback invoked before the loop starts.
ServiceDomainInfoUpdated domainInfoUpdated
Callback invoked when we get updated about the oldest possible timeslice we can process.
ServiceDanglingCallback preDangling
Callback executed before the dangling inputs loop.
ServicePostForwarding postForwarding
ServiceStopCallback stop
Callback invoked on Start.
ServiceStartCallback start
Callback invoked on Start.
ServiceEOSCallback preEOS
Callback executed before the end of stream callback of the user happended.
ServicePreSendingMessages preSendingMessages
Callback invoked when we are about sending a message.
ServiceProcessingCallback postProcessing
Callback executed once actual processing happened.
ServicePostRenderGUI postRenderGUI
Callback invoked after the main GUI has been drawn.
ServiceProcessingCallback finaliseOutputs
ServicePostDispatching postDispatching
ServiceEOSCallback postEOS
Callback executed after the end of stream callback of the user happended.
std::vector< ServiceProcessingHandle > postProcessingHandles
Callbacks for services to be executed after every process method invokation.
std::vector< ServiceStartStreamHandle > preStartStreamHandles
std::vector< ServiceProcessingHandle > finaliseOutputsHandles
std::vector< ServiceProcessingHandle > preProcessingHandles
Callbacks for services to be executed before every process method invokation.