Project
Loading...
Searching...
No Matches
FairMQDeviceProxy.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_FAIRMQDEVICEPROXY_H_
12#define O2_FRAMEWORK_FAIRMQDEVICEPROXY_H_
13
14#include <memory>
15
22#include <fairmq/FwdDecls.h>
23#include <vector>
24
25namespace o2::header
26{
27struct DataHeader;
28};
29
30namespace o2::framework
31{
36{
37 public:
38 FairMQDeviceProxy() = default;
40 void bind(std::vector<OutputRoute> const& outputs, std::vector<InputRoute> const& inputs,
41 std::vector<ForwardRoute> const& forwards, fair::mq::Device& device);
42
44 [[nodiscard]] fair::mq::TransportFactory* getOutputTransport(RouteIndex routeIndex) const;
46 [[nodiscard]] fair::mq::TransportFactory* getInputTransport(RouteIndex routeIndex) const;
48 [[nodiscard]] fair::mq::TransportFactory* getForwardTransport(RouteIndex routeIndex) const;
50 [[nodiscard]] ChannelIndex getOutputChannelIndexByName(std::string const& channelName) const;
52 [[nodiscard]] ChannelIndex getInputChannelIndexByName(std::string const& channelName) const;
54 [[nodiscard]] ChannelIndex getForwardChannelIndexByName(std::string const& channelName) const;
56 [[nodiscard]] ChannelIndex getOutputChannelIndex(OutputSpec const& spec, size_t timeslice) const;
58 void getMatchingForwardChannelIndexes(std::vector<ChannelIndex>& result, header::DataHeader const& header, size_t timeslice) const;
60 [[nodiscard]] ChannelIndex getOutputChannelIndex(RouteIndex routeIndex) const;
61 [[nodiscard]] ChannelIndex getInputChannelIndex(RouteIndex routeIndex) const;
62 [[nodiscard]] ChannelIndex getForwardChannelIndex(RouteIndex routeIndex) const;
64 [[nodiscard]] fair::mq::Channel* getInputChannel(ChannelIndex channelIndex) const;
65 [[nodiscard]] fair::mq::Channel* getOutputChannel(ChannelIndex channelIndex) const;
66 [[nodiscard]] fair::mq::Channel* getForwardChannel(ChannelIndex channelIndex) const;
67
69 [[nodiscard]] OutputChannelInfo const& getOutputChannelInfo(ChannelIndex channelIndex) const;
71 [[nodiscard]] ForwardChannelInfo const& getForwardChannelInfo(ChannelIndex channelIndex) const;
72
77
78 [[nodiscard]] std::unique_ptr<fair::mq::Message> createOutputMessage(RouteIndex routeIndex) const;
79 [[nodiscard]] std::unique_ptr<fair::mq::Message> createOutputMessage(RouteIndex routeIndex, const size_t size) const;
80
81 [[nodiscard]] std::unique_ptr<fair::mq::Message> createInputMessage(RouteIndex routeIndex) const;
82 [[nodiscard]] std::unique_ptr<fair::mq::Message> createInputMessage(RouteIndex routeIndex, const size_t size) const;
83
84 [[nodiscard]] std::unique_ptr<fair::mq::Message> createForwardMessage(RouteIndex routeIndex) const;
85
86 [[nodiscard]] size_t getNumOutputChannels() const { return mOutputChannelInfos.size(); }
87 [[nodiscard]] size_t getNumInputChannels() const { return mInputChannels.size(); }
88 [[nodiscard]] size_t getNumForwardChannels() const { return mForwardChannelInfos.size(); }
89 [[nodiscard]] size_t getNumForwards() const { return mForwards.size(); }
90
91 [[nodiscard]] bool newStateRequested() const { return mStateChangeCallback(); }
92
93 private:
94 std::vector<OutputRoute> mOutputs;
95 std::vector<RouteState> mOutputRoutes;
96 std::vector<OutputChannelInfo> mOutputChannelInfos;
97 std::vector<OutputChannelState> mOutputChannelStates;
98
99 std::vector<InputRoute> mInputs;
100 std::vector<RouteState> mInputRoutes;
101 std::vector<fair::mq::Channel*> mInputChannels;
102 std::vector<std::string> mInputChannelNames;
103
104 std::vector<ForwardRoute> mForwards;
105 std::vector<RouteState> mForwardRoutes;
106 std::vector<ForwardChannelInfo> mForwardChannelInfos;
107 std::vector<ForwardChannelState> mForwardChannelStates;
108
109 std::function<bool()> mStateChangeCallback;
110};
111
112} // namespace o2::framework
113
114#endif // O2_FRAMEWORK_FAIRMQDEVICEPROXY_H_
std::unique_ptr< fair::mq::Message > createOutputMessage(RouteIndex routeIndex) const
ForwardChannelState & getForwardChannelState(ChannelIndex channelIndex)
Retrieve information associated to a given forward by ChannelIndex.
fair::mq::TransportFactory * getForwardTransport(RouteIndex routeIndex) const
Retrieve the transport associated to a given route.
OutputChannelState & getOutputChannelState(ChannelIndex channelIndex)
Retrieve information associated to a given forward by ChannelIndex.
ChannelIndex getInputChannelIndexByName(std::string const &channelName) const
ChannelIndex from a given channel name.
ChannelIndex getForwardChannelIndexByName(std::string const &channelName) const
ChannelIndex from a given channel name.
ChannelIndex getForwardChannelIndex(RouteIndex routeIndex) const
void getMatchingForwardChannelIndexes(std::vector< ChannelIndex > &result, header::DataHeader const &header, size_t timeslice) const
Retrieve the channel index from a given OutputSpec and the associated timeslice.
ForwardChannelInfo const & getForwardChannelInfo(ChannelIndex channelIndex) const
Retrieve information associated to a given forward by ChannelIndex.
ChannelIndex getOutputChannelIndexByName(std::string const &channelName) const
ChannelIndex from a given channel name.
fair::mq::Channel * getForwardChannel(ChannelIndex channelIndex) const
fair::mq::TransportFactory * getOutputTransport(RouteIndex routeIndex) const
Retrieve the transport associated to a given route.
ChannelIndex getOutputChannelIndex(OutputSpec const &spec, size_t timeslice) const
Retrieve the channel index from a given OutputSpec and the associated timeslice.
fair::mq::Channel * getOutputChannel(ChannelIndex channelIndex) const
void bind(std::vector< OutputRoute > const &outputs, std::vector< InputRoute > const &inputs, std::vector< ForwardRoute > const &forwards, fair::mq::Device &device)
std::unique_ptr< fair::mq::Message > createForwardMessage(RouteIndex routeIndex) const
fair::mq::Channel * getInputChannel(ChannelIndex channelIndex) const
Retrieve the channel associated to a given output route.
ChannelIndex getInputChannelIndex(RouteIndex routeIndex) const
OutputChannelInfo const & getOutputChannelInfo(ChannelIndex channelIndex) const
Retrieve information associated to a given forward by ChannelIndex.
fair::mq::TransportFactory * getInputTransport(RouteIndex routeIndex) const
Retrieve the transport associated to a given route.
std::unique_ptr< fair::mq::Message > createInputMessage(RouteIndex routeIndex) const
FairMQDeviceProxy(FairMQDeviceProxy const &)=delete
GLuint64EXT * result
Definition glcorearb.h:5662
GLsizeiptr size
Definition glcorearb.h:659
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
O2 data header classes and API, v0.1.
Definition DetID.h:49
Forward channel information.
Definition ChannelInfo.h:88
Output channel information.
Definition ChannelInfo.h:73
the main header struct
Definition DataHeader.h:618