ATLAS Offline Software
v5_Guid.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ====================================================================
6 //
7 // Guid.cpp
8 // --------------------------------------------------------------------
9 //
10 // Package : Persistent Guid to identify objects in the persistent
11 // world.
12 //
13 // Author : Markus Frank
14 //
15 // ====================================================================
16 #define POOL_GUID_CPP 1
17 //$Id: v5_Guid.cxx 732100 2016-03-24 05:58:02Z salnikov $
18 #include "v5_Guid.h"
19 #include <cstdio>
20 #include <cstring>
21 
22 #include "uuid/uuid.h"
23 
24 static const char* const fmt_Guid =
25  "%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX";
26 
27 //{ 0x0,0x0,0x0,{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}};
28 static const offline_poolCopy_v5::Guid
29  clid_null(std::string("00000000-0000-0000-0000-000000000000"));
30 
32  return clid_null;
33 }
34 
37  uuid_t me_;
38  ::uuid_generate_time(me_);
39  unsigned int *d1=(unsigned int*)me_;
40  unsigned short *d2=(unsigned short*)(me_+4);
41  unsigned short *d3=(unsigned short*)(me_+6);
42  guid.Data1 = *d1;
43  guid.Data2 = *d2;
44  guid.Data3 = *d3;
45  for (int i=0; i<8; i++){
46  guid.Data4[i]=me_[i+8];
47  }
48 }
49 
50 const std::string offline_poolCopy_v5::Guid::toString() const {
51  char text[128];
52  ::snprintf(text, 128, fmt_Guid,
53  static_cast<long unsigned int>(Data1),
54  Data2, Data3,
55  Data4[0], Data4[1], Data4[2], Data4[3],
56  Data4[4], Data4[5], Data4[6], Data4[7]);
57  return text;
58 }
59 
61  // Note: This looks funny, but the specs for sscanf formats say
62  // that the space of a pointer in the ellipsis may only be
63  // integer or short. Hence one has to reserve a bit more space
64  // otherwise the stack gets corrupted.
65  unsigned char d[8];
66  long unsigned int xData1;
67  ::sscanf( source.c_str(), fmt_Guid, &xData1, &Data2, &Data3,
68  &Data4[0], &Data4[1], &Data4[2], &Data4[3], &d[0], &d[1], &d[2], &d[3]);
69  Data1 = xData1;
70  //*(int*)&Data4[4] = *(int*)d;
71  ::memcpy(Data4+4, d, 4);
72  return *this;
73 }
74 
76  return ::memcmp(&g.Data1, &Data1, 16) < 0;
77 }
offline_poolCopy_v5::Guid::operator<
bool operator<(const Guid &g) const
Smaller operator.
Definition: v5_Guid.cxx:75
v5_Guid.h
hist_file_dump.d
d
Definition: hist_file_dump.py:137
offline_poolCopy_v5::Guid::toString
const std::string toString() const
Automatic conversion from string reprentation.
Definition: v5_Guid.cxx:50
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
offline_poolCopy_v5::Guid
Definition: v5_Guid.h:33
offline_poolCopy_v5::Guid::create
static void create(Guid &guid)
Create a new Guid.
Definition: v5_Guid.cxx:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
pool_uuid.guid
guid
Definition: pool_uuid.py:112
offline_poolCopy_v5::Guid::null
static const Guid & null()
NULL-Guid: static class method.
Definition: v5_Guid.cxx:31
offline_poolCopy_v5::Guid::fromString
const Guid & fromString(const std::string &s)
Automatic conversion to string representation.
Definition: v5_Guid.cxx:60
dq_defect_virtual_defect_validation.d2
d2
Definition: dq_defect_virtual_defect_validation.py:81
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
copySelective.source
string source
Definition: copySelective.py:32