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