ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaBarCodeImpl.h
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef ATHENABARCODEIMPL_H
8#define ATHENABARCODEIMPL_H
9
18// //
20
21// STL includes
22
23#include <inttypes.h>
24
25#include <iosfwd>
26#include <atomic>
27
28#include <AthenaKernel/IAthenaBarCode.h> //for static const data memebers
30//
31// Universal Object Identifier for all INav4Mom Objects
32//
34
35class StatusCode;
36
38 friend class AthenaBarCodeCnv_p1;
39
40public:
41 static const unsigned short TotalBits = 64;
42
43 static const unsigned short UUIDBits = 32;
44 static const unsigned short CounterBits = 26;
45 static const unsigned short VersionBits = 4;
46 static const unsigned short ReserveBits = 2;
47
48 static const unsigned short SUUIDBits = 0;
49 static const unsigned short SCounterBits = UUIDBits;
50 static const unsigned short SVersionBits = UUIDBits+CounterBits;
51 static const unsigned short SReserveBits = UUIDBits+CounterBits+VersionBits;
52
53
54public:
55 //Constructors
56
57 virtual ~AthenaBarCodeImpl() = default;
58
62
63public:
64 //Public setter and getters
67
68public:
69 //Comparing & Versioning Control
70 bool hasSameAthenaBarCode(const IAthenaBarCode &obj) const;
72
74 void newVersion();
75 void setVersion(AthenaBarCodeVersion_t newversion);
76
77 std::ostream& dump(std::ostream& out) const;
78
79 //True if the athenabarcode is created in this job, meaning a newly created object. False if the object is read from a file.
80 bool createdInCurrentJob() const;
81
82 //Handle reserved bits, mainly for read back of older version of AthenaBarCode when the configuration of #bits for UUID,counter and version bits are different from the current one.
85
86 // Used to set the default hash when JobIDSvc is not being used.
87 // Should not be called within Athena.
88 static void setDefaultHash (const char* jobid);
89
90protected:
91 void setBits(unsigned short startbit,unsigned short nbits,AthenaBarCode_t id,
92 AthenaBarCode_t& bc) const;
93 AthenaBarCode_t getBits(unsigned short startbit,unsigned short nbits) const ;
94 void initABC() const ;
95
96private:
97 //UUID related
99 static AthenaBarCode_t hashUUID(const char *);
100
101 void setUUIDHash(AthenaBarCode_t uuidhash);
104
105 static AthenaBarCode_t getDefaultHash (const char* jobid = nullptr);
106 static AthenaBarCode_t makeDefaultHash (const char* jobid);
107
108 //data fields
109 static std::atomic<AthenaBarCode_t> m_barcodeCounter;
110 mutable std::atomic<AthenaBarCode_t> m_barcode;
111
112};
113
117
118
120 const AthenaBarCode_t &hash) const {
121
122 AthenaBarCode_t tmp = 0;
123 AthenaBarCode_t lowerh = ~tmp >> (TotalBits
124 - UUIDBits);
125 AthenaBarCode_t higherh = ~tmp << (UUIDBits);
126
127 AthenaBarCode_t lower = m_barcode & lowerh;
128 AthenaBarCode_t higher = hash & higherh;
129
130 /*
131 std::cout << "AthenaBarCodeImpl::combineWithHash::hash=" << std::hex
132 << hash << " lower=" << lower << " higher=" << higher << " lowerh="
133 << lowerh << " higherh=" << higherh << " barcode=" << (lower
134 | higher) << std::endl;
135 */
136 return lower | higher;
137
138}
139
140#endif // not NAVIGATION_ATHENABARCODE_H
uint64_t AthenaBarCode_t
barcode for all INav4Mom classes
AthenaBarCode_t AthenaBarCodeVersion_t
static const unsigned short ReserveBits
void setBits(unsigned short startbit, unsigned short nbits, AthenaBarCode_t id, AthenaBarCode_t &bc) const
static AthenaBarCode_t makeDefaultHash(const char *jobid)
static const unsigned short SUUIDBits
void setReserveBits(AthenaBarCode_t id)
AthenaBarCode_t hasUUIDHash() const
AthenaBarCode_t getUUIDHash() const
static const unsigned short UUIDBits
virtual ~AthenaBarCodeImpl()=default
static void setDefaultHash(const char *jobid)
AthenaBarCode_t getBits(unsigned short startbit, unsigned short nbits) const
std::atomic< AthenaBarCode_t > m_barcode
static const unsigned short CounterBits
static const unsigned short SCounterBits
static AthenaBarCode_t getDefaultHash(const char *jobid=nullptr)
bool hasSameAthenaBarCodeExceptVersion(const IAthenaBarCode &obj) const
AthenaBarCodeVersion_t getVersion() const
void setAthenaBarCode(AthenaBarCode_t id)
static const unsigned short SVersionBits
void setUUIDHash(AthenaBarCode_t uuidhash)
bool createdInCurrentJob() const
AthenaBarCode_t getAthenaBarCode() const
friend class AthenaBarCodeCnv_p1
void setVersion(AthenaBarCodeVersion_t newversion)
static const unsigned short VersionBits
static const unsigned short TotalBits
AthenaBarCodeImpl & operator=(const AthenaBarCodeImpl &)
static const unsigned short SReserveBits
static AthenaBarCode_t hashUUID(const char *)
AthenaBarCode_t getReserveBits() const
static std::atomic< AthenaBarCode_t > m_barcodeCounter
bool hasSameAthenaBarCode(const IAthenaBarCode &obj) const
AthenaBarCode_t combineWithUUIDHash(const AthenaBarCode_t &) const
-event-from-file