mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
FairMQ: Add plugin mechanism (Plugin and PluginManager classes)
This commit is contained in:
committed by
Mohammad Al-Turany
parent
ac69607250
commit
60d929b0bd
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <fairmq/tools/CppSTL.h>
|
||||
#include <fairmq/tools/Network.h>
|
||||
#include <fairmq/tools/Strings.h>
|
||||
|
||||
namespace FairMQ
|
||||
{
|
||||
@@ -17,6 +18,8 @@ using fair::mq::tools::getHostIPs;
|
||||
using fair::mq::tools::getInterfaceIP;
|
||||
using fair::mq::tools::getDefaultRouteNetworkInterface;
|
||||
|
||||
using fair::mq::tools::S;
|
||||
|
||||
} // namespace tools
|
||||
} // namespace FairMQ
|
||||
|
||||
|
@@ -36,7 +36,7 @@ namespace tools
|
||||
{
|
||||
|
||||
// returns a map with network interface names as keys and their IP addresses as values
|
||||
int getHostIPs(std::map<std::string, std::string>& addressMap)
|
||||
inline int getHostIPs(std::map<std::string, std::string>& addressMap)
|
||||
{
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
int s;
|
||||
@@ -73,7 +73,7 @@ int getHostIPs(std::map<std::string, std::string>& addressMap)
|
||||
}
|
||||
|
||||
// get IP address of a given interface name
|
||||
std::string getInterfaceIP(std::string interface)
|
||||
inline std::string getInterfaceIP(std::string interface)
|
||||
{
|
||||
std::map<std::string, std::string> IPs;
|
||||
getHostIPs(IPs);
|
||||
@@ -89,7 +89,7 @@ std::string getInterfaceIP(std::string interface)
|
||||
}
|
||||
|
||||
// get name of the default route interface
|
||||
std::string getDefaultRouteNetworkInterface()
|
||||
inline std::string getDefaultRouteNetworkInterface()
|
||||
{
|
||||
std::array<char, 128> buffer;
|
||||
std::string interfaceName;
|
||||
|
53
fairmq/tools/Strings.h
Normal file
53
fairmq/tools/Strings.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/********************************************************************************
|
||||
* 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" *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef FAIR_MQ_TOOLS_STRINGS_H
|
||||
#define FAIR_MQ_TOOLS_STRINGS_H
|
||||
|
||||
#include <initializer_list>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
namespace mq
|
||||
{
|
||||
namespace tools
|
||||
{
|
||||
|
||||
/// @brief concatenates a variable number of args with the << operator via a stringstream
|
||||
/// @param t objects to be concatenated
|
||||
/// @return concatenated string
|
||||
template<typename ... T>
|
||||
auto ToString(T&&... t) -> std::string
|
||||
{
|
||||
std::stringstream ss;
|
||||
(void)std::initializer_list<int>{(ss << t, 0)...};
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
/// @brief convert command line arguments from main function to vector of strings
|
||||
inline auto ToStrVector(const int argc, const char* argv[], const bool dropProgramName = true) -> std::vector<std::string>
|
||||
{
|
||||
auto res = std::vector<std::string>{};
|
||||
if (dropProgramName)
|
||||
{
|
||||
res.assign(argv + 1, argv + argc);
|
||||
} else
|
||||
{
|
||||
res.assign(argv, argv + argc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
} /* namespace tools */
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
||||
|
||||
#endif /* FAIR_MQ_TOOLS_STRINGS_H */
|
Reference in New Issue
Block a user