FairMQ  1.2.1
C++ Message Passing Framework
Unique.h
1 /********************************************************************************
2  * Copyright (C) 2017 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 #ifndef FAIR_MQ_TOOLS_UNIQUE_H
10 #define FAIR_MQ_TOOLS_UNIQUE_H
11 
12 #include <boost/uuid/uuid.hpp>
13 #include <boost/uuid/uuid_generators.hpp>
14 #include <boost/uuid/uuid_io.hpp>
15 #include <boost/functional/hash.hpp>
16 
17 #include <string>
18 
19 namespace fair
20 {
21 namespace mq
22 {
23 namespace tools
24 {
25 
26 // generates UUID string
27 inline std::string Uuid()
28 {
29  boost::uuids::random_generator gen;
30  boost::uuids::uuid u = gen();
31  return boost::uuids::to_string(u);
32 }
33 
34 // generates UUID and returns its hash
35 inline std::size_t UuidHash()
36 {
37  boost::uuids::random_generator gen;
38  boost::hash<boost::uuids::uuid> uuid_hasher;
39  boost::uuids::uuid u = gen();
40  return uuid_hasher(u);
41 }
42 
43 } /* namespace tools */
44 } /* namespace mq */
45 } /* namespace fair */
46 
47 #endif /* FAIR_MQ_TOOLS_UNIQUE_H */
Definition: DeviceRunner.h:23