UUIDGenerator.h
Go to the documentation of this file.
1 #ifndef _RMS_UUID_H
2 #define _RMS_UUID_H
3 
4 /**
5  * @package gov.fnal.cd.rms.util
6  *
7  * @brief A collection of classes that simplify miscellaneous
8  * tasks.
9  *
10  * The util package contains helper classes for managing threads,
11  * parsing time and date strings, generating UUIDs as well as
12  * thread safe data structures.
13  */
14 
15 #include <rms/util/Sha1.h>
16 
17 #include <boost/random/linear_congruential.hpp>
18 #include <boost/random/uniform_int.hpp>
19 #include <boost/random/variate_generator.hpp>
20 
21 #include <string>
22 #include <sys/time.h>
23 
24 namespace gov {
25 
26 namespace fnal {
27 
28 namespace cd {
29 
30 namespace rms {
31 
32 namespace util {
33 
34 /**
35  * This class generates time based type 1 UUIDs, as specified in RFC4122.
36  *
37  * @author Kurt Biery
38  * @author Steve Foulkes
39  * @version $Revision: 1.1.1.1.18.1 $ $Date: 2019/09/27 00:07:32 $
40  */
41 
43  public:
44  UUIDGenerator(std::string nodeName);
45 
46  const std::string getUUIDHex();
47  const char *getUUID();
48 
49  private:
50  /**
51  * The time at which the last UUID was generated.
52  */
53  struct timeval _previousTime;
54 
55  /**
56  * This is used to differentiate UUIDs that are generated within the
57  * same clock tick
58  */
60 
61  /**
62  * The name of the node that is generating the UUIDs. This should
63  * be unique.
64  */
66 
67  /**
68  * An SHA1 hash of the nodename
69  */
70  unsigned char _nodeNameHash[20];
71 
72  /**
73  * The clock sequence, a 16 bit random number
74  */
75  unsigned char _clockSequence[2];
76 
77 };
78 
79 } // end of namespace util
80 
81 } // end of namespace rms
82 
83 } // end of namespace cd
84 
85 } // end of namespace fnal
86 
87 } // end of namespace gov
88 
89 #endif
Filter events based on their run/event numbers.
Definition: fnal.py:1
c cd(1)
enum BeamMode string