-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathCcdbObjectInfo.h
More file actions
133 lines (112 loc) · 4.63 KB
/
CcdbObjectInfo.h
File metadata and controls
133 lines (112 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef O2_CCDB_CCDBOBJECTINFO_H_
#define O2_CCDB_CCDBOBJECTINFO_H_
#include <Rtypes.h>
#include <utility>
#include "Framework/Logger.h"
/// @brief information complementary to a CCDB object (path, metadata, startTimeValidity, endTimeValidity etc)
namespace o2::ccdb
{
class CcdbObjectInfo
{
public:
// time intervals in milliseconds
static constexpr long SECOND = 1000;
static constexpr long MINUTE = 60 * SECOND;
static constexpr long HOUR = 60 * MINUTE;
static constexpr long DAY = 24 * HOUR;
static constexpr long MONTH = 30 * DAY;
static constexpr long YEAR = 364 * DAY;
static constexpr long INFINITE_TIMESTAMP = 9999999999999;
static constexpr long INFINITE_TIMESTAMP_SECONDS = 2000000000; // not really inifinity, but close to std::numeric_limits<int>::max() till 18.05.2033
static constexpr const char* AdjustableEOV = "adjustableEOV";
static constexpr const char* DefaultObj = "default";
CcdbObjectInfo(bool adjustableEOV = true)
{
if (adjustableEOV) {
setAdjustableEOV();
}
}
CcdbObjectInfo(std::string path, std::string objType, std::string flName,
std::map<std::string, std::string> metadata,
long startValidityTimestamp, long endValidityTimestamp, bool adjustableEOV = true, bool validateUpload = false)
: mObjType(std::move(objType)), mFileName(std::move(flName)), mPath(std::move(path)), mMD(std::move(metadata)), mStart(startValidityTimestamp), mEnd(endValidityTimestamp), mValidateUpload(validateUpload)
{
if (adjustableEOV) {
setAdjustableEOV();
}
}
~CcdbObjectInfo() = default;
[[nodiscard]] const std::string& getObjectType() const { return mObjType; }
void setObjectType(const std::string& tp) { mObjType = tp; }
[[nodiscard]] const std::string& getFileName() const { return mFileName; }
void setFileName(const std::string& nm) { mFileName = nm; }
[[nodiscard]] const std::string& getPath() const { return mPath; }
void setPath(const std::string& path) { mPath = path; }
[[nodiscard]] const std::map<std::string, std::string>& getMetaData() const { return mMD; }
void setMetaData(const std::map<std::string, std::string>& md)
{
mMD = md;
if (mAdjustableEOV) {
setAdjustableEOV();
}
}
void setAdjustableEOV()
{
mAdjustableEOV = true;
if (mMD.find(DefaultObj) != mMD.end()) {
LOGP(fatal, "default object cannot have adjustable EOV, {}", mPath);
}
if (mMD.find(AdjustableEOV) == mMD.end()) {
mMD[AdjustableEOV] = "true";
}
}
void setValidateUpload(bool v) { mValidateUpload = v; }
bool isAdjustableEOV() const { return mAdjustableEOV; }
bool getValidateUpload() const { return mValidateUpload; }
[[nodiscard]] long getStartValidityTimestamp() const { return mStart; }
void setStartValidityTimestamp(long start) { mStart = start; }
[[nodiscard]] long getEndValidityTimestamp() const { return mEnd; }
void setEndValidityTimestamp(long end) { mEnd = end; }
bool operator<(const CcdbObjectInfo& other) const
{
return mStart < other.mStart;
}
bool operator>(const CcdbObjectInfo& other) const
{
return mStart > other.mStart;
}
private:
std::string mObjType{}; // object type (e.g. class)
std::string mFileName{}; // file name in the CCDB
std::string mPath{}; // path in the CCDB
std::map<std::string, std::string> mMD; // metadata
long mStart = 0; // start of the validity of the object
long mEnd = 0; // end of the validity of the object
bool mAdjustableEOV = false; // each new object may override EOV of object it overrides to its own SOV
bool mValidateUpload = false; // request to validate the upload by querying its header
ClassDefNV(CcdbObjectInfo, 3);
};
} // namespace o2::ccdb
namespace std
{
// defining std::hash for InteractionRecord to be used with std containers
template <>
struct hash<o2::ccdb::CcdbObjectInfo> {
public:
size_t operator()(const o2::ccdb::CcdbObjectInfo& info) const
{
return info.getStartValidityTimestamp();
}
};
} // namespace std
#endif // O2_CCDB_CCDBOBJECTINFO_H_