mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-12 16:21:13 +00:00
Add Version member to FairMQDevice, settable via constructor
This commit is contained in:
parent
3d8175bfd6
commit
65f1b96dc3
|
@ -73,6 +73,38 @@ FairMQDevice::FairMQDevice()
|
||||||
, fMultitransportMutex()
|
, fMultitransportMutex()
|
||||||
, fMultitransportProceed(false)
|
, fMultitransportProceed(false)
|
||||||
, fExternalConfig(false)
|
, fExternalConfig(false)
|
||||||
|
, fVersion({0, 0, 0})
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQDevice::FairMQDevice(const fair::mq::tools::Version version)
|
||||||
|
: fChannels()
|
||||||
|
, fConfig(nullptr)
|
||||||
|
, fId()
|
||||||
|
, fNumIoThreads(1)
|
||||||
|
, fTransportFactory(nullptr)
|
||||||
|
, fTransports()
|
||||||
|
, fInitialValidationFinished(false)
|
||||||
|
, fInitialValidationCondition()
|
||||||
|
, fInitialValidationMutex()
|
||||||
|
, fPortRangeMin(22000)
|
||||||
|
, fPortRangeMax(32000)
|
||||||
|
, fNetworkInterface()
|
||||||
|
, fDefaultTransport()
|
||||||
|
, fInitializationTimeoutInS(120)
|
||||||
|
, fCatchingSignals(false)
|
||||||
|
, fTerminationRequested(false)
|
||||||
|
, fInteractiveRunning(false)
|
||||||
|
, fDataCallbacks(false)
|
||||||
|
, fDeviceCmdSockets()
|
||||||
|
, fMsgInputs()
|
||||||
|
, fMultipartInputs()
|
||||||
|
, fMultitransportInputs()
|
||||||
|
, fInputChannelKeys()
|
||||||
|
, fMultitransportMutex()
|
||||||
|
, fMultitransportProceed(false)
|
||||||
|
, fExternalConfig(false)
|
||||||
|
, fVersion(version)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
|
#include <fairmq/Tools.h>
|
||||||
|
|
||||||
typedef std::unordered_map<std::string, std::vector<FairMQChannel>> FairMQChannelMap;
|
typedef std::unordered_map<std::string, std::vector<FairMQChannel>> FairMQChannelMap;
|
||||||
|
|
||||||
typedef std::function<bool(FairMQMessagePtr&, int)> InputMsgCallback;
|
typedef std::function<bool(FairMQMessagePtr&, int)> InputMsgCallback;
|
||||||
|
@ -53,6 +55,9 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
|
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
FairMQDevice();
|
FairMQDevice();
|
||||||
|
|
||||||
|
/// Constructor that sets the version
|
||||||
|
FairMQDevice(const fair::mq::tools::Version version);
|
||||||
/// Copy constructor (disabled)
|
/// Copy constructor (disabled)
|
||||||
FairMQDevice(const FairMQDevice&) = delete;
|
FairMQDevice(const FairMQDevice&) = delete;
|
||||||
/// Assignment operator (disabled)
|
/// Assignment operator (disabled)
|
||||||
|
@ -428,23 +433,25 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
void SetId(const std::string& id) { fId = id; }
|
void SetId(const std::string& id) { fId = id; }
|
||||||
std::string GetId() { return fId; }
|
std::string GetId() { return fId; }
|
||||||
|
|
||||||
|
const fair::mq::tools::Version GetVersion() const { return fVersion; }
|
||||||
|
|
||||||
void SetNumIoThreads(int numIoThreads) { fNumIoThreads = numIoThreads; }
|
void SetNumIoThreads(int numIoThreads) { fNumIoThreads = numIoThreads; }
|
||||||
int GetNumIoThreads() { return fNumIoThreads; }
|
int GetNumIoThreads() const { return fNumIoThreads; }
|
||||||
|
|
||||||
void SetPortRangeMin(int portRangeMin) { fPortRangeMin = portRangeMin; }
|
void SetPortRangeMin(int portRangeMin) { fPortRangeMin = portRangeMin; }
|
||||||
int GetPortRangeMin() { return fPortRangeMin; }
|
int GetPortRangeMin() const { return fPortRangeMin; }
|
||||||
|
|
||||||
void SetPortRangeMax(int portRangeMax) { fPortRangeMax = portRangeMax; }
|
void SetPortRangeMax(int portRangeMax) { fPortRangeMax = portRangeMax; }
|
||||||
int GetPortRangeMax() { return fPortRangeMax; }
|
int GetPortRangeMax() const { return fPortRangeMax; }
|
||||||
|
|
||||||
void SetNetworkInterface(const std::string& networkInterface) { fNetworkInterface = networkInterface; }
|
void SetNetworkInterface(const std::string& networkInterface) { fNetworkInterface = networkInterface; }
|
||||||
std::string GetNetworkInterface() { return fNetworkInterface; }
|
std::string GetNetworkInterface() const { return fNetworkInterface; }
|
||||||
|
|
||||||
void SetDefaultTransport(const std::string& defaultTransport) { fDefaultTransport = defaultTransport; }
|
void SetDefaultTransport(const std::string& defaultTransport) { fDefaultTransport = defaultTransport; }
|
||||||
std::string GetDefaultTransport() { return fDefaultTransport; }
|
std::string GetDefaultTransport() const { return fDefaultTransport; }
|
||||||
|
|
||||||
void SetInitializationTimeoutInS(int initializationTimeoutInS) { fInitializationTimeoutInS = initializationTimeoutInS; }
|
void SetInitializationTimeoutInS(int initializationTimeoutInS) { fInitializationTimeoutInS = initializationTimeoutInS; }
|
||||||
int GetInitializationTimeoutInS() { return fInitializationTimeoutInS; }
|
int GetInitializationTimeoutInS() const { return fInitializationTimeoutInS; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<FairMQTransportFactory> fTransportFactory; ///< Transport factory
|
std::shared_ptr<FairMQTransportFactory> fTransportFactory; ///< Transport factory
|
||||||
|
@ -560,6 +567,8 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
std::atomic<bool> fMultitransportProceed;
|
std::atomic<bool> fMultitransportProceed;
|
||||||
|
|
||||||
bool fExternalConfig;
|
bool fExternalConfig;
|
||||||
|
|
||||||
|
const fair::mq::tools::Version fVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQDEVICE_H_ */
|
#endif /* FAIRMQDEVICE_H_ */
|
||||||
|
|
|
@ -74,9 +74,9 @@ void FairMQProgOptions::ParseAll(const int argc, char const* const* argv, bool a
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fVarMap.count("print-channels"))
|
// if these options are provided, do no further checks and let the device handle them
|
||||||
|
if (fVarMap.count("print-channels") || fVarMap.count("version"))
|
||||||
{
|
{
|
||||||
// if this option is provided, do no further checks and let the device print the channels
|
|
||||||
DefaultConsoleSetFilter(fSeverityMap.at("NOLOG"));
|
DefaultConsoleSetFilter(fSeverityMap.at("NOLOG"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -298,12 +298,6 @@ int FairMQProgOptions::NotifySwitchOption()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fVarMap.count("version"))
|
|
||||||
{
|
|
||||||
LOG(INFO) << fVersion << "\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,11 @@ int main(int argc, const char** argv)
|
||||||
|
|
||||||
int result = runStateMachine(*device, config);
|
int result = runStateMachine(*device, config);
|
||||||
|
|
||||||
|
if (config.Count("version"))
|
||||||
|
{
|
||||||
|
pluginManager->ForEachPlugin([](fair::mq::Plugin& plugin){ std::cout << "plugin: " << plugin << std::endl; });
|
||||||
|
}
|
||||||
|
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -68,8 +68,10 @@ add_testsuite(FairMQ.Device
|
||||||
SOURCES
|
SOURCES
|
||||||
device/TestSender.h
|
device/TestSender.h
|
||||||
device/TestReceiver.h
|
device/TestReceiver.h
|
||||||
|
device/TestVersion.h
|
||||||
device/runner.cxx
|
device/runner.cxx
|
||||||
device/_multiple_devices.cxx
|
device/_multiple_devices.cxx
|
||||||
|
device/_device_version.cxx
|
||||||
|
|
||||||
LINKS FairMQ
|
LINKS FairMQ
|
||||||
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/device
|
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/device
|
||||||
|
|
30
fairmq/test/device/TestVersion.h
Normal file
30
fairmq/test/device/TestVersion.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2015-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
|
* *
|
||||||
|
* This software is distributed under the terms of the *
|
||||||
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include <FairMQDevice.h>
|
||||||
|
#include <FairMQLogger.h>
|
||||||
|
#include <options/FairMQProgOptions.h>
|
||||||
|
|
||||||
|
namespace fair
|
||||||
|
{
|
||||||
|
namespace mq
|
||||||
|
{
|
||||||
|
namespace test
|
||||||
|
{
|
||||||
|
|
||||||
|
class TestVersion : public FairMQDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TestVersion(fair::mq::tools::Version version)
|
||||||
|
: FairMQDevice(version)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace test
|
||||||
|
} // namespace mq
|
||||||
|
} // namespace fair
|
46
fairmq/test/device/_device_version.cxx
Normal file
46
fairmq/test/device/_device_version.cxx
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
|
* *
|
||||||
|
* This software is distributed under the terms of the *
|
||||||
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "TestVersion.h"
|
||||||
|
|
||||||
|
#include <fairmq/Tools.h>
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include <sstream> // std::stringstream
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace fair::mq::test;
|
||||||
|
|
||||||
|
class DeviceVersion : public ::testing::Test {
|
||||||
|
public:
|
||||||
|
DeviceVersion()
|
||||||
|
{}
|
||||||
|
|
||||||
|
fair::mq::tools::Version TestDeviceVersion()
|
||||||
|
{
|
||||||
|
fair::mq::test::TestVersion versionDevice({1, 2, 3});
|
||||||
|
versionDevice.ChangeState("END");
|
||||||
|
|
||||||
|
return versionDevice.GetVersion();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(DeviceVersion, getter)
|
||||||
|
{
|
||||||
|
struct fair::mq::tools::Version v{1, 2, 3};
|
||||||
|
fair::mq::tools::Version version = TestDeviceVersion();
|
||||||
|
|
||||||
|
EXPECT_EQ(v, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
|
@ -11,6 +11,8 @@
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
#include "options/FairMQParser.h"
|
#include "options/FairMQParser.h"
|
||||||
#include "options/FairMQProgOptions.h"
|
#include "options/FairMQProgOptions.h"
|
||||||
|
#include <FairMQDevice.h>
|
||||||
|
#include <fairmq/PluginManager.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -30,6 +32,15 @@ inline int runStateMachine(TMQDevice& device, FairMQProgOptions& cfg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg.Count("version"))
|
||||||
|
{
|
||||||
|
std::cout << "User device version: " << device.GetVersion() << std::endl;
|
||||||
|
std::cout << "FAIRMQ_INTERFACE_VERSION: " << FAIRMQ_INTERFACE_VERSION << std::endl;
|
||||||
|
|
||||||
|
device.ChangeState(TMQDevice::END);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg.GetValue<int>("catch-signals") > 0)
|
if (cfg.GetValue<int>("catch-signals") > 0)
|
||||||
{
|
{
|
||||||
device.CatchSignals();
|
device.CatchSignals();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user