Skip to content

Commit 33cfcb9

Browse files
committed
fix: Adopt fair::mq::Device::GetChannels() API
Since FairMQ 1.5.0: ``` warning: ‘fair::mq::Device::fChannels’ is deprecated: Use GetChannels() instead. ``` see FairRootGroup/FairMQ@5ef17fd FairMQ 1.4 is still supported, so we need to maintain a switch.
1 parent 66709b8 commit 33cfcb9

5 files changed

Lines changed: 30 additions & 12 deletions

File tree

examples/MQ/histogramServer/FairMQExHistoDevice.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -8,6 +8,7 @@
88

99
#include "FairMQExHistoDevice.h"
1010

11+
#include "FairMQ.h"
1112
#include "RootSerializer.h"
1213

1314
#include <TMath.h>
@@ -55,7 +56,7 @@ bool FairMQExHistoDevice::ConditionalRun()
5556
auto message(NewMessage());
5657
RootSerializer().Serialize(*message, &fArrayHisto);
5758

58-
for (auto& channel : fChannels) {
59+
for (auto& channel : fairroot::GetFairMQDeviceChannels(*this)) {
5960
Send(message, channel.first);
6061
}
6162

examples/MQ/pixelDetector/src/devices/FairMQRunDevice.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
@@ -14,6 +14,7 @@
1414

1515
#include "FairMQRunDevice.h"
1616

17+
#include "FairMQ.h"
1718
#include "FairOnlineSink.h"
1819
#include "FairRootManager.h"
1920
#include "RootSerializer.h"
@@ -23,7 +24,6 @@
2324
#include <TObjString.h>
2425
#include <cstdio> // printf
2526
#include <fairlogger/Logger.h>
26-
2727
#include <mutex> // std::mutex
2828
std::mutex mtx; // mutex for critical section
2929

@@ -66,7 +66,7 @@ void FairMQRunDevice::SendBranches(FairOnlineSink& sink)
6666

6767
TList* branchNameList = FairRootManager::Instance()->GetBranchNameList();
6868

69-
for (auto& mi : fChannels) {
69+
for (auto& mi : fairroot::GetFairMQDeviceChannels(*this)) {
7070
LOG(debug) << "trying channel >" << mi.first << "<";
7171

7272
fair::mq::Parts parts;

fairroot/basemq/devices/FairMQLmdSampler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -245,8 +245,8 @@ class FairMQLmdSampler : public fair::mq::Device
245245
fair::mq::Parts parts;
246246

247247
// send header
248-
// auto header(fTransportFactory->CreateMessage(fSubEvent, sizeof(fSubEvent),
249-
// free_buffer, nullptr)); fChannels.at(chanName).at(0).SendPart(header);
248+
// auto header(fTransportFactory->CreateMessage(fSubEvent, sizeof(fSubEvent), free_buffer, nullptr));
249+
// GetChannel(chanName, 0).SendPart(header);
250250

251251
int* arraySize = new int(sebuflength);
252252

fairroot/basemq/devices/FairMQUnpacker.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -88,7 +88,9 @@ class FairMQUnpacker : public fair::mq::Device
8888
}
8989

9090
// check if given channel exist
91-
if (!fChannels.count(fInputChannelName)) {
91+
try {
92+
GetChannel(fInputChannelName);
93+
} catch (const std::out_of_range&) {
9294
throw std::runtime_error(std::string("MQ-channel name '") + fInputChannelName
9395
+ "' does not exist. Check the MQ-channel configuration");
9496
}
@@ -105,7 +107,7 @@ class FairMQUnpacker : public fair::mq::Device
105107

106108
void Run()
107109
{
108-
fair::mq::Channel& inputChannel = fChannels.at(fInputChannelName).at(0);
110+
auto& inputChannel = GetChannel(fInputChannelName);
109111

110112
while (!NewStatePending()) {
111113
auto msgSize(NewMessage());

fairroot/fairmq/FairMQ.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2022-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -53,4 +53,19 @@ using TransportFactory = ::FairMQTransportFactory;
5353

5454
#endif
5555

56+
namespace fairroot
57+
{
58+
59+
// see https://github.com/FairRootGroup/FairMQ/commit/5ef17fddbb6a957867cd6aca978176bc95c63508
60+
inline auto& GetFairMQDeviceChannels(fair::mq::Device& device)
61+
{
62+
#if FAIRMQ_VERSION_DEC < 105000
63+
return device.fChannels;
64+
#else
65+
return device.GetChannels();
66+
#endif
67+
}
68+
69+
} // namespace fairroot
70+
5671
#endif // FAIRROOT_FAIRMQ_H

0 commit comments

Comments
 (0)