Module: check_mk
Branch: master
Commit: 1e28cf732cf26f87fa7b5f5891bf8fa6b35932be
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1e28cf732cf26f…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Oct 27 10:13:23 2017 +0200
Be explicit about which columns have a filtering capability.
Change-Id: Ic3a5f59f268b74b812e17c9f03067faaf0630b60
---
livestatus/src/BlobColumn.cc | 7 +++++++
livestatus/src/BlobColumn.h | 11 +++++++++--
livestatus/src/Column.cc | 6 ------
livestatus/src/Column.h | 2 +-
livestatus/src/NullColumn.cc | 7 +++++++
livestatus/src/NullColumn.h | 8 ++++++++
6 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/livestatus/src/BlobColumn.cc b/livestatus/src/BlobColumn.cc
index 6cf2aa9..00908de 100644
--- a/livestatus/src/BlobColumn.cc
+++ b/livestatus/src/BlobColumn.cc
@@ -23,6 +23,7 @@
// Boston, MA 02110-1301 USA.
#include "BlobColumn.h"
+#include <stdexcept>
#include "Renderer.h"
#include "Row.h"
@@ -34,3 +35,9 @@ void BlobColumn::output(Row row, RowRenderer &r,
r.output(Null());
}
}
+
+std::unique_ptr<Filter> BlobColumn::createFilter(
+ RelationalOperator /*unused*/, const std::string & /*unused*/) const {
+ throw std::runtime_error("filtering on blob column " + name() +
+ " not supported");
+}
diff --git a/livestatus/src/BlobColumn.h b/livestatus/src/BlobColumn.h
index c205864..451b948 100644
--- a/livestatus/src/BlobColumn.h
+++ b/livestatus/src/BlobColumn.h
@@ -31,6 +31,8 @@
#include <vector>
#include "Column.h"
#include "contact_fwd.h"
+#include "opids.h"
+class Filter;
class Row;
class RowRenderer;
@@ -41,10 +43,15 @@ public:
int offset)
: Column(name, description, indirect_offset, extra_offset,
extra_extra_offset, offset) {}
- virtual std::unique_ptr<std::vector<char>> getBlob(Row row) const = 0;
+ ColumnType type() const override { return ColumnType::blob; }
+
void output(Row row, RowRenderer &r,
const contact *auth_user) const override;
- ColumnType type() const override { return ColumnType::blob; }
+
+ std::unique_ptr<Filter> createFilter(
+ RelationalOperator relOp, const std::string &value) const override;
+
+ virtual std::unique_ptr<std::vector<char>> getBlob(Row row) const = 0;
};
#endif // BlobColumn_h
diff --git a/livestatus/src/Column.cc b/livestatus/src/Column.cc
index 0d122b7..a3675f7 100644
--- a/livestatus/src/Column.cc
+++ b/livestatus/src/Column.cc
@@ -23,7 +23,6 @@
// Boston, MA 02110-1301 USA.
#include "Column.h"
-#include <stdexcept>
#include <utility>
#include "Logger.h"
@@ -57,11 +56,6 @@ const void *Column::shiftPointer(Row row) const {
_offset);
}
-std::unique_ptr<Filter> Column::createFilter(
- RelationalOperator /*unused*/, const std::string & /*unused*/) const {
- throw std::runtime_error("filtering on column " + _name + " not
supported");
-}
-
std::unique_ptr<Aggregator> Column::createAggregator(
StatsOperation /*unused*/) const {
return nullptr;
diff --git a/livestatus/src/Column.h b/livestatus/src/Column.h
index 48365ba..1eff6ba 100644
--- a/livestatus/src/Column.h
+++ b/livestatus/src/Column.h
@@ -65,7 +65,7 @@ public:
const contact *auth_user) const = 0;
virtual std::unique_ptr<Filter> createFilter(
- RelationalOperator relOp, const std::string &value) const;
+ RelationalOperator relOp, const std::string &value) const = 0;
virtual std::unique_ptr<Aggregator> createAggregator(
StatsOperation operation) const;
diff --git a/livestatus/src/NullColumn.cc b/livestatus/src/NullColumn.cc
index 4f098ee..c08d4b0 100644
--- a/livestatus/src/NullColumn.cc
+++ b/livestatus/src/NullColumn.cc
@@ -23,10 +23,17 @@
// Boston, MA 02110-1301 USA.
#include "NullColumn.h"
+#include <stdexcept>
#include "Renderer.h"
#include "Row.h"
+class Filter;
void NullColumn::output(Row /* row */, RowRenderer& r,
const contact* /* auth_user */) const {
r.output(Null());
}
+
+std::unique_ptr<Filter> NullColumn::createFilter(
+ RelationalOperator /*unused*/, const std::string& /*unused*/) const {
+ throw std::runtime_error("filtering on null column not supported");
+}
diff --git a/livestatus/src/NullColumn.h b/livestatus/src/NullColumn.h
index b10b376..2d1bf4d 100644
--- a/livestatus/src/NullColumn.h
+++ b/livestatus/src/NullColumn.h
@@ -26,9 +26,12 @@
#define NullColumn_h
#include "config.h" // IWYU pragma: keep
+#include <memory>
#include <string>
#include "Column.h"
#include "contact_fwd.h"
+#include "opids.h"
+class Filter;
class Row;
class RowRenderer;
@@ -39,9 +42,14 @@ public:
int offset)
: Column(name, description, indirect_offset, extra_offset,
extra_extra_offset, offset) {}
+
ColumnType type() const override { return ColumnType::null; }
+
void output(Row row, RowRenderer &r,
const contact *auth_user) const override;
+
+ std::unique_ptr<Filter> createFilter(
+ RelationalOperator relOp, const std::string &value) const override;
};
#endif // NullColumn_h