Skip to content

Source · fairmq/

TransportFactory.cxxsource

Described in Messages and multipart, Transports, region: unmanaged regions, Use channels without a device, Use std::pmr memory resources, Poll several channels, Send your own data types, Test your devices, Overview.

fairmq/TransportFactory.cxx50 lines · C++GitHub ↗
1/********************************************************************************2 * Copyright (C) 2017-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH  *3 *                                                                              *4 *              This software is distributed under the terms of the             *5 *              GNU Lesser General Public Licence (LGPL) version 3,             *6 *                  copied verbatim in the file "LICENSE"                       *7 ********************************************************************************/8 9#include <fairmq/TransportFactory.h>10#include <fairmq/shmem/TransportFactory.h>11#include <fairmq/zeromq/TransportFactory.h>12#include <fairlogger/Logger.h>13#include <fairmq/Tools.h>14#include <memory>15#include <string>16#include <utility>   // move17 18using namespace std;19 20namespace fair::mq {21 22auto TransportFactory::CreateTransportFactory(const string& type,23                                              const string& id,24                                              const ProgOptions* config)25    -> shared_ptr<TransportFactory>26{27    auto finalId = id;28 29    // Generate uuid if empty30    if (finalId.empty()) {31        finalId = tools::Uuid();32    }33 34    if (type == "zeromq") {35        return make_shared<zmq::TransportFactory>(finalId, config);36    } else if (type == "shmem") {37        return make_shared<shmem::TransportFactory>(finalId, config);38    }39    else {40        LOG(error) << "Unavailable transport requested: "41                   << "\"" << type << "\""42                   << ". Available are: "43                   << "\"zeromq\","44                   << "\"shmem\""45                   << ". Exiting.";46        throw TransportFactoryError(tools::ToString("Unavailable transport requested: ", type));47    }48}49 50}   // namespace fair::mq