FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairRunIdGenerator.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 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 #ifndef FAIRRUNIDGENERATOR_H
9 #define FAIRRUNIDGENERATOR_H
10 
11 #include <time.h> // IWYU pragma: keep for timespec
12 // IWYU pragma: no_include <sys/_structs.h>
13 
14 typedef unsigned char uint8_t;
15 typedef unsigned short int uint16_t;
16 typedef unsigned int uint32_t;
17 typedef unsigned char uuid_t[16];
18 
20 {
21  struct uuid
22  {
23  uint32_t time_low;
24  uint16_t time_mid;
25  uint16_t time_hi_and_version;
26  uint16_t clock_seq;
27  uint8_t node[6];
28  };
29 
30  struct timespec fTimeSpec;
31 
32  int get_random_fd(void);
33  void get_random_bytes(void*, int);
34  int get_node_id(unsigned char*);
35  int get_clock(uint32_t*, uint32_t*, uint16_t*);
36  void uuid_generate_time(uuid_t);
37  void uuid_generate_random(uuid_t);
38  void uuid_generate(uuid_t);
39  void uuid_pack(const struct uuid*, uuid_t);
40  void uuid_unpack(const uuid_t, struct uuid*);
41 
42  public:
43  struct timespec getTimeSpec() { return fTimeSpec; }
44  struct timespec getTimeSpecFromTID(unsigned int ms);
45  unsigned int getTID();
46 
47  public:
49  : fTimeSpec()
50  {}
52  unsigned int generateId(void);
53 };
54 
55 #endif
unsigned char uuid_t[16]
struct timespec getTimeSpecFromTID(unsigned int ms)
unsigned int generateId(void)
unsigned char uint8_t
unsigned short int uint16_t
struct timespec getTimeSpec()
unsigned int uint32_t