mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
FairMQ: Add uuid generator to tools & let tests use it for session names.
This commit is contained in:
committed by
Mohammad Al-Turany
parent
85aab51bd4
commit
0dc4000187
@@ -7,6 +7,7 @@
|
||||
#include <fairmq/tools/Network.h>
|
||||
#include <fairmq/tools/Strings.h>
|
||||
#include <fairmq/tools/Version.h>
|
||||
#include <fairmq/tools/Unique.h>
|
||||
|
||||
namespace FairMQ
|
||||
{
|
||||
@@ -22,6 +23,9 @@ using fair::mq::tools::getDefaultRouteNetworkInterface;
|
||||
|
||||
using fair::mq::tools::S;
|
||||
|
||||
using fair::mq::tools::Uuid;
|
||||
using fair::mq::tools::UuidHash;
|
||||
|
||||
using fair::mq::tools::Version;
|
||||
|
||||
} // namespace tools
|
||||
|
47
fairmq/tools/Unique.h
Normal file
47
fairmq/tools/Unique.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/********************************************************************************
|
||||
* 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_UNIQUE_H
|
||||
#define FAIR_MQ_TOOLS_UNIQUE_H
|
||||
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace fair
|
||||
{
|
||||
namespace mq
|
||||
{
|
||||
namespace tools
|
||||
{
|
||||
|
||||
// generates UUID string
|
||||
inline std::string Uuid()
|
||||
{
|
||||
boost::uuids::random_generator gen;
|
||||
boost::uuids::uuid u = gen();
|
||||
return boost::uuids::to_string(u);
|
||||
}
|
||||
|
||||
// generates UUID and returns its hash
|
||||
inline std::size_t UuidHash()
|
||||
{
|
||||
boost::uuids::random_generator gen;
|
||||
boost::hash<boost::uuids::uuid> uuid_hasher;
|
||||
boost::uuids::uuid u = gen();
|
||||
return uuid_hasher(u);
|
||||
}
|
||||
|
||||
} /* namespace tools */
|
||||
} /* namespace mq */
|
||||
} /* namespace fair */
|
||||
|
||||
#endif /* FAIR_MQ_TOOLS_UNIQUE_H */
|
Reference in New Issue
Block a user