Module: check_mk
Branch: master
Commit: d0cd1f0cda82e0c89d5693da41e0f498a2cc3e05
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d0cd1f0cda82e0…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Nov 3 15:52:27 2017 +0100
Improved TimeColumn::getValue() return type.
Change-Id: I14262e9fbf2cf9d4dd6b7c817b1b56dec7a29595
---
livestatus/src/OffsetTimeColumn.cc | 8 ++++----
livestatus/src/OffsetTimeColumn.h | 5 +++--
livestatus/src/TableEventConsole.h | 6 +++---
livestatus/src/TimeAggregator.cc | 3 ++-
livestatus/src/TimeColumn.cc | 2 +-
livestatus/src/TimeColumn.h | 4 ++--
livestatus/src/TimeFilter.cc | 3 ++-
livestatus/src/TimePointerColumn.h | 6 +++---
8 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/livestatus/src/OffsetTimeColumn.cc b/livestatus/src/OffsetTimeColumn.cc
index 32c40ec..727c673 100644
--- a/livestatus/src/OffsetTimeColumn.cc
+++ b/livestatus/src/OffsetTimeColumn.cc
@@ -26,10 +26,10 @@
#include <ctime>
#include "Row.h"
-int32_t OffsetTimeColumn::getValue(Row row,
- const contact* /* auth_user */) const {
+std::chrono::system_clock::time_point OffsetTimeColumn::getValue(
+ Row row, const contact* /* auth_user */) const {
if (auto p = columnData<time_t>(row)) {
- return static_cast<int32_t>(*p);
+ return std::chrono::system_clock::from_time_t(*p);
}
- return 0;
+ return std::chrono::system_clock::time_point();
}
diff --git a/livestatus/src/OffsetTimeColumn.h b/livestatus/src/OffsetTimeColumn.h
index 04809ea..a931b2e 100644
--- a/livestatus/src/OffsetTimeColumn.h
+++ b/livestatus/src/OffsetTimeColumn.h
@@ -26,7 +26,7 @@
#define OffsetTimeColumn_h
#include "config.h" // IWYU pragma: keep
-#include <cstdint>
+#include <chrono>
#include <string>
#include "TimeColumn.h"
#include "contact_fwd.h"
@@ -40,7 +40,8 @@ public:
: TimeColumn(name, description, indirect_offset, extra_offset,
extra_extra_offset, offset) {}
- int32_t getValue(Row row, const contact* auth_user) const override;
+ std::chrono::system_clock::time_point getValue(
+ Row row, const contact* auth_user) const override;
};
#endif // OffsetTimeColumn_h
diff --git a/livestatus/src/TableEventConsole.h b/livestatus/src/TableEventConsole.h
index f0b7d53..f44b564 100644
--- a/livestatus/src/TableEventConsole.h
+++ b/livestatus/src/TableEventConsole.h
@@ -135,9 +135,9 @@ protected:
return static_cast<int32_t>(atof(x.c_str()));
}) {}
- int32_t getValue(Row row,
- const contact * /* auth_user */) const override {
- return _ecc.getValue(row);
+ std::chrono::system_clock::time_point getValue(
+ Row row, const contact * /* auth_user */) const override {
+ return std::chrono::system_clock::from_time_t(_ecc.getValue(row));
}
};
diff --git a/livestatus/src/TimeAggregator.cc b/livestatus/src/TimeAggregator.cc
index 76d7362..63242c3 100644
--- a/livestatus/src/TimeAggregator.cc
+++ b/livestatus/src/TimeAggregator.cc
@@ -33,7 +33,8 @@ void TimeAggregator::consume(Row row, const contact *auth_user,
std::chrono::seconds /* timezone_offset */) {
_count++;
// NOTE: TimeColumn::getValue() call site
- int32_t value = _column->getValue(row, auth_user);
+ int32_t value =
+ std::chrono::system_clock::to_time_t(_column->getValue(row, auth_user));
switch (getOperation()) {
case StatsOperation::sum:
case StatsOperation::avg:
diff --git a/livestatus/src/TimeColumn.cc b/livestatus/src/TimeColumn.cc
index 0469c5c..5e765e1 100644
--- a/livestatus/src/TimeColumn.cc
+++ b/livestatus/src/TimeColumn.cc
@@ -33,7 +33,7 @@
void TimeColumn::output(Row row, RowRenderer &r, const contact *auth_user,
std::chrono::seconds /*timezone_offset*/) const {
// NOTE: TimeColumn::getValue() call site
- r.output(std::chrono::system_clock::from_time_t(getValue(row, auth_user)));
+ r.output(getValue(row, auth_user));
}
std::unique_ptr<Filter> TimeColumn::createFilter(
diff --git a/livestatus/src/TimeColumn.h b/livestatus/src/TimeColumn.h
index 82fb36f..d33a57d 100644
--- a/livestatus/src/TimeColumn.h
+++ b/livestatus/src/TimeColumn.h
@@ -27,7 +27,6 @@
#include "config.h" // IWYU pragma: keep
#include <chrono>
-#include <cstdint>
#include <memory>
#include <string>
#include "Aggregator.h"
@@ -57,7 +56,8 @@ public:
std::unique_ptr<Aggregator> createAggregator(
StatsOperation operation) const override;
- virtual int32_t getValue(Row row, const contact *auth_user) const = 0;
+ virtual std::chrono::system_clock::time_point getValue(
+ Row row, const contact *auth_user) const = 0;
};
#endif // TimeColumn_h
diff --git a/livestatus/src/TimeFilter.cc b/livestatus/src/TimeFilter.cc
index c24e693..4aeea1a 100644
--- a/livestatus/src/TimeFilter.cc
+++ b/livestatus/src/TimeFilter.cc
@@ -43,7 +43,8 @@ int32_t TimeFilter::convertRefValue(
bool TimeFilter::accepts(Row row, const contact *auth_user,
std::chrono::seconds timezone_offset) const {
// NOTE: TimeColumn::getValue() call site
- int32_t act_value = _column.getValue(row, auth_user);
+ int32_t act_value =
+ std::chrono::system_clock::to_time_t(_column.getValue(row, auth_user));
int32_t ref_value = convertRefValue(timezone_offset);
switch (_relOp) {
case RelationalOperator::equal:
diff --git a/livestatus/src/TimePointerColumn.h b/livestatus/src/TimePointerColumn.h
index 99b6723..fc910c4 100644
--- a/livestatus/src/TimePointerColumn.h
+++ b/livestatus/src/TimePointerColumn.h
@@ -39,9 +39,9 @@ public:
const time_t *number)
: TimeColumn(name, description, -1, -1, -1, 0), _number(number) {}
- int32_t getValue(Row /* row */,
- const contact * /* auth_user */) const override {
- return static_cast<int32_t>(*_number);
+ std::chrono::system_clock::time_point getValue(
+ Row /* row */, const contact * /* auth_user */) const override {
+ return std::chrono::system_clock::from_time_t(*_number);
}
private: