Module: check_mk
Branch: master
Commit: 909155871ea4e131d86b662e529e6a7361f82ec2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=909155871ea4e1…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Mar 27 14:12:02 2019 +0100
Inline 2 trivial helper functions.
This unifies access to custom variables a bit.
Change-Id: Ib757f7ec15f6c646831fc381181313fd717a1743
---
livestatus/src/CustomTimeperiodColumn.cc | 18 ++++++------------
livestatus/src/CustomTimeperiodColumn.h | 2 --
livestatus/src/CustomVarsExplicitColumn.cc | 17 ++++++-----------
livestatus/src/CustomVarsExplicitColumn.h | 3 ---
4 files changed, 12 insertions(+), 28 deletions(-)
diff --git a/livestatus/src/CustomTimeperiodColumn.cc
b/livestatus/src/CustomTimeperiodColumn.cc
index 2acdad4..5b919f6 100644
--- a/livestatus/src/CustomTimeperiodColumn.cc
+++ b/livestatus/src/CustomTimeperiodColumn.cc
@@ -32,19 +32,13 @@ extern TimeperiodsCache *g_timeperiods_cache;
// state of that period
int32_t CustomTimeperiodColumn::getValue(
Row row, const contact * /* auth_user */) const {
- for (customvariablesmember *cvm = getCVM(row); cvm != nullptr;
- cvm = cvm->next) {
- if (cvm->variable_name == _varname) {
- return static_cast<int32_t>(
- g_timeperiods_cache->inTimeperiod(cvm->variable_value));
+ if (auto p = columnData<customvariablesmember *>(row)) {
+ for (auto cvm = *p; cvm != nullptr; cvm = cvm->next) {
+ if (cvm->variable_name == _varname) {
+ return static_cast<int32_t>(
+ g_timeperiods_cache->inTimeperiod(cvm->variable_value));
+ }
}
}
return 1; // assume 24X7
}
-
-customvariablesmember *CustomTimeperiodColumn::getCVM(Row row) const {
- if (auto p = columnData<customvariablesmember *>(row)) {
- return *p;
- }
- return nullptr;
-}
diff --git a/livestatus/src/CustomTimeperiodColumn.h
b/livestatus/src/CustomTimeperiodColumn.h
index c8ca82b..9a93608 100644
--- a/livestatus/src/CustomTimeperiodColumn.h
+++ b/livestatus/src/CustomTimeperiodColumn.h
@@ -46,8 +46,6 @@ public:
private:
std::string _varname;
-
- customvariablesmember *getCVM(Row row) const;
};
#endif // CustomTimeperiodColumn_h
diff --git a/livestatus/src/CustomVarsExplicitColumn.cc
b/livestatus/src/CustomVarsExplicitColumn.cc
index 82d69af..dfe2112 100644
--- a/livestatus/src/CustomVarsExplicitColumn.cc
+++ b/livestatus/src/CustomVarsExplicitColumn.cc
@@ -24,20 +24,15 @@
#include "CustomVarsExplicitColumn.h"
#include "Row.h"
+#include "nagios.h"
std::string CustomVarsExplicitColumn::getValue(Row row) const {
- for (customvariablesmember *cvm = getCVM(row); cvm != nullptr;
- cvm = cvm->next) {
- if (cvm->variable_name == _varname) {
- return cvm->variable_value;
+ if (auto p = columnData<customvariablesmember *>(row)) {
+ for (auto cvm = *p; cvm != nullptr; cvm = cvm->next) {
+ if (cvm->variable_name == _varname) {
+ return cvm->variable_value;
+ }
}
}
return "";
}
-
-customvariablesmember *CustomVarsExplicitColumn::getCVM(Row row) const {
- if (auto p = columnData<customvariablesmember *>(row)) {
- return *p;
- }
- return nullptr;
-}
diff --git a/livestatus/src/CustomVarsExplicitColumn.h
b/livestatus/src/CustomVarsExplicitColumn.h
index 4254348..33d7064 100644
--- a/livestatus/src/CustomVarsExplicitColumn.h
+++ b/livestatus/src/CustomVarsExplicitColumn.h
@@ -28,7 +28,6 @@
#include "config.h" // IWYU pragma: keep
#include <string>
#include "StringColumn.h"
-#include "nagios.h"
class Row;
class CustomVarsExplicitColumn : public StringColumn {
@@ -45,8 +44,6 @@ public:
private:
std::string _varname;
-
- customvariablesmember *getCVM(Row row) const;
};
#endif // CustomVarsExplicitColumn_h