GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/util/uuid.h
Date: 2024-04-28 02:33:07
Exec Total Coverage
Lines: 4 4 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_UTIL_UUID_H_
6 #define CVMFS_UTIL_UUID_H_
7
8 #include <inttypes.h>
9 #include <uuid/uuid.h>
10
11 #include <string>
12
13 #include "util/export.h"
14
15 namespace cvmfs {
16
17 /**
18 * Holds a unique identifies which is either read from a file or, if the file
19 * does not yet exist, created and stored in a file. This is how it is used to
20 * identify a cvmfs cache directory.
21 *
22 * In order to create many UUIDs for short-lived objects, use the CreateOneTime
23 * factory method.
24 */
25 class CVMFS_EXPORT Uuid {
26 public:
27 static Uuid *Create(const std::string &store_path);
28 static std::string CreateOneTime();
29 105 std::string uuid() const { return uuid_; }
30 300021 const unsigned char *data() const {
31 300021 return reinterpret_cast<const unsigned char *>(&uuid_presentation_.uuid);
32 }
33 300021 unsigned size() const { return sizeof(uuid_presentation_.uuid); }
34
35 private:
36 void MkUuid();
37 Uuid();
38
39 std::string uuid_;
40 union {
41 uuid_t uuid;
42 struct __attribute__((__packed__)) {
43 uint32_t a;
44 uint16_t b;
45 uint16_t c;
46 uint16_t d;
47 uint32_t e1;
48 uint16_t e2;
49 } split;
50 } uuid_presentation_;
51 };
52
53 } // namespace cvmfs
54
55 #endif // CVMFS_UTIL_UUID_H_
56