hmbdc
simplify-high-performance-messaging-programming
 All Classes Namespaces Functions Variables Friends Pages
Uuid.hpp
1 #include "hmbdc/Copyright.hpp"
2 #pragma once
3 
4 #include <iostream>
5 #include <random>
6 #include <stdint.h>
7 
8 namespace hmbdc { namespace comm {
9 
10 struct Uuid {
11  static Uuid generate() {
12  std::uniform_int_distribution<uint64_t> dist(1, 0xfffffffffffffffful);
13  Uuid res;
14  res.v_ = dist(gen_s);
15  return res;
16  }
17 
18  bool operator == (Uuid const& other) const {
19  return v_ == other.v_;
20  }
21 
22  friend
23  std::ostream& operator << (std::ostream& os, Uuid const& t) {
24  return os << t.v_;
25  }
26  friend
27  std::istream& operator >> (std::istream& is, Uuid& t) {
28  return is >> t.v_;
29  }
30  static thread_local std::random_device rd_s;
31  static thread_local std::default_random_engine gen_s;
32 
33 private:
34  uint64_t v_;
35 
36 };
37 }}
Definition: Uuid.hpp:10