mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
move TransportFactory factory into FairMQTransportFactory namespace
This commit is contained in:
parent
f522dc1717
commit
97ca52aa0e
|
@ -874,33 +874,7 @@ shared_ptr<FairMQTransportFactory> FairMQDevice::AddTransport(const string& tran
|
||||||
|
|
||||||
if (i == fTransports.end())
|
if (i == fTransports.end())
|
||||||
{
|
{
|
||||||
shared_ptr<FairMQTransportFactory> tr;
|
auto tr = FairMQTransportFactory::CreateTransportFactory(transport);
|
||||||
|
|
||||||
if (transport == "zeromq")
|
|
||||||
{
|
|
||||||
tr = make_shared<FairMQTransportFactoryZMQ>();
|
|
||||||
}
|
|
||||||
else if (transport == "shmem")
|
|
||||||
{
|
|
||||||
tr = make_shared<FairMQTransportFactorySHM>();
|
|
||||||
}
|
|
||||||
#ifdef NANOMSG_FOUND
|
|
||||||
else if (transport == "nanomsg")
|
|
||||||
{
|
|
||||||
tr = make_shared<FairMQTransportFactoryNN>();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(ERROR) << "Unavailable transport requested: " << "\"" << transport << "\"" << ". Available are: "
|
|
||||||
<< "\"zeromq\""
|
|
||||||
<< "\"shmem\""
|
|
||||||
#ifdef NANOMSG_FOUND
|
|
||||||
<< ", \"nanomsg\""
|
|
||||||
#endif
|
|
||||||
<< ". Exiting.";
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(DEBUG) << "Adding '" << transport << "' transport to the device.";
|
LOG(DEBUG) << "Adding '" << transport << "' transport to the device.";
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2012-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
/**
|
|
||||||
* FairMQDevice.h
|
|
||||||
*
|
|
||||||
* @since 2012-10-25
|
|
||||||
* @author D. Klein, A. Rybalchenko
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FAIRMQDEVICE_H_
|
#ifndef FAIRMQDEVICE_H_
|
||||||
#define FAIRMQDEVICE_H_
|
#define FAIRMQDEVICE_H_
|
||||||
|
|
||||||
|
#include "FairMQConfigurable.h"
|
||||||
|
#include "FairMQStateMachine.h"
|
||||||
|
#include "FairMQTransportFactory.h"
|
||||||
|
#include "FairMQTransports.h"
|
||||||
|
|
||||||
|
#include "FairMQSocket.h"
|
||||||
|
#include "FairMQChannel.h"
|
||||||
|
#include "FairMQMessage.h"
|
||||||
|
#include "FairMQParts.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory> // unique_ptr
|
#include <memory> // unique_ptr
|
||||||
#include <algorithm> // std::sort()
|
#include <algorithm> // std::sort()
|
||||||
|
@ -28,16 +32,6 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
#include "FairMQConfigurable.h"
|
|
||||||
#include "FairMQStateMachine.h"
|
|
||||||
#include "FairMQTransportFactory.h"
|
|
||||||
#include "FairMQTransports.h"
|
|
||||||
|
|
||||||
#include "FairMQSocket.h"
|
|
||||||
#include "FairMQChannel.h"
|
|
||||||
#include "FairMQMessage.h"
|
|
||||||
#include "FairMQParts.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;
|
||||||
|
|
|
@ -1,13 +1,45 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
/**
|
|
||||||
* FairMQTransportFactory.cxx
|
#include <FairMQTransportFactory.h>
|
||||||
*
|
#include <zeromq/FairMQTransportFactoryZMQ.h>
|
||||||
* @since 2014-01-20
|
#include <shmem/FairMQTransportFactorySHM.h>
|
||||||
* @author: A. Rybalchenko
|
#ifdef NANOMSG_FOUND
|
||||||
*/
|
#include <nanomsg/FairMQTransportFactoryNN.h>
|
||||||
|
#endif /* NANOMSG_FOUND */
|
||||||
|
#include <FairMQLogger.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
auto FairMQTransportFactory::CreateTransportFactory(const std::string& type) -> std::shared_ptr<FairMQTransportFactory>
|
||||||
|
{
|
||||||
|
if (type == "zeromq")
|
||||||
|
{
|
||||||
|
return std::make_shared<FairMQTransportFactoryZMQ>();
|
||||||
|
}
|
||||||
|
else if (type == "shmem")
|
||||||
|
{
|
||||||
|
return std::make_shared<FairMQTransportFactorySHM>();
|
||||||
|
}
|
||||||
|
#ifdef NANOMSG_FOUND
|
||||||
|
else if (type == "nanomsg")
|
||||||
|
{
|
||||||
|
return std::make_shared<FairMQTransportFactoryNN>();
|
||||||
|
}
|
||||||
|
#endif /* NANOMSG_FOUND */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "Unavailable transport requested: " << "\"" << type << "\"" << ". Available are: "
|
||||||
|
<< "\"zeromq\""
|
||||||
|
<< "\"shmem\""
|
||||||
|
#ifdef NANOMSG_FOUND
|
||||||
|
<< ", \"nanomsg\""
|
||||||
|
#endif /* NANOMSG_FOUND */
|
||||||
|
<< ". Exiting.";
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ class FairMQTransportFactory
|
||||||
virtual void Terminate() = 0;
|
virtual void Terminate() = 0;
|
||||||
|
|
||||||
virtual ~FairMQTransportFactory() {};
|
virtual ~FairMQTransportFactory() {};
|
||||||
|
|
||||||
|
static auto CreateTransportFactory(const std::string& type) -> std::shared_ptr<FairMQTransportFactory>;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQTRANSPORTFACTORY_H_ */
|
#endif /* FAIRMQTRANSPORTFACTORY_H_ */
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -22,7 +23,7 @@ using namespace std;
|
||||||
class RandomAccessIterator : public ::testing::Test {
|
class RandomAccessIterator : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
FairMQParts mParts;
|
FairMQParts mParts;
|
||||||
FairMQTransportFactoryZMQ mFactory;
|
shared_ptr<FairMQTransportFactory> mFactory;
|
||||||
const string mS1, mS2, mS3;
|
const string mS1, mS2, mS3;
|
||||||
|
|
||||||
RandomAccessIterator()
|
RandomAccessIterator()
|
||||||
|
@ -32,13 +33,9 @@ class RandomAccessIterator : public ::testing::Test {
|
||||||
mS2("2"),
|
mS2("2"),
|
||||||
mS3("3")
|
mS3("3")
|
||||||
{
|
{
|
||||||
|
mParts.AddPart(mFactory->NewSimpleMessage(mS1));
|
||||||
mParts.AddPart(mFactory.CreateMessage(const_cast<char*>(mS1.c_str()),
|
mParts.AddPart(mFactory->NewSimpleMessage(mS2));
|
||||||
mS1.length(), FairMQDevice::FairMQSimpleMsgCleanup<string>));
|
mParts.AddPart(mFactory->NewSimpleMessage(mS3));
|
||||||
mParts.AddPart(mFactory.CreateMessage(const_cast<char*>(mS2.c_str()),
|
|
||||||
mS2.length(), FairMQDevice::FairMQSimpleMsgCleanup<string>));
|
|
||||||
mParts.AddPart(mFactory.CreateMessage(const_cast<char*>(mS3.c_str()),
|
|
||||||
mS3.length(), FairMQDevice::FairMQSimpleMsgCleanup<string>));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,8 +54,7 @@ TEST_F(RandomAccessIterator, RangeForLoopMutation)
|
||||||
auto s = string{"4"};
|
auto s = string{"4"};
|
||||||
|
|
||||||
for (auto&& part : mParts) {
|
for (auto&& part : mParts) {
|
||||||
part = mFactory.CreateMessage(const_cast<char*>(s.c_str()),
|
part = mFactory->NewSimpleMessage(s);
|
||||||
s.length(), FairMQDevice::FairMQSimpleMsgCleanup<string>);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stringstream out;
|
stringstream out;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user