Module: check_mk
Branch: master
Commit: 154cf31ee1489f6355a05fe2fb6dffa0382c8b8d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=154cf31ee1489f…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Nov 10 14:47:00 2017 +0100
Improved typing of FilterVisitor.
Change-Id: Icb1ae71d4df3f00c582f2a81ef9e61b60f2a9826
---
livestatus/src/AndingFilter.h | 2 ++
livestatus/src/FilterVisitor.h | 6 ++++--
livestatus/src/OringFilter.h | 2 ++
livestatus/src/TableStateHistory.cc | 11 ++++++-----
livestatus/src/VariadicFilter.h | 2 --
5 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/livestatus/src/AndingFilter.h b/livestatus/src/AndingFilter.h
index c399f67..8e4133a 100644
--- a/livestatus/src/AndingFilter.h
+++ b/livestatus/src/AndingFilter.h
@@ -53,6 +53,8 @@ public:
const std::string &column_name) const;
std::unique_ptr<Filter> stealLastSubFilter();
size_t size() const { return _subfilters.size(); }
+ auto begin() const { return _subfilters.begin(); }
+ auto end() const { return _subfilters.end(); }
};
#endif // AndingFilter_h
diff --git a/livestatus/src/FilterVisitor.h b/livestatus/src/FilterVisitor.h
index 02eb4e6..6028b8c 100644
--- a/livestatus/src/FilterVisitor.h
+++ b/livestatus/src/FilterVisitor.h
@@ -26,14 +26,16 @@
#define FilterVisitor_h
#include "config.h" // IWYU pragma: keep
+class AndingFilter;
class ColumnFilter;
-class VariadicFilter;
+class OringFilter;
class FilterVisitor {
public:
virtual ~FilterVisitor() {}
virtual void visit(const ColumnFilter &) = 0;
- virtual void visit(const VariadicFilter &) = 0;
+ virtual void visit(const AndingFilter &) = 0;
+ virtual void visit(const OringFilter &) = 0;
};
#endif // FilterVisitor_h
diff --git a/livestatus/src/OringFilter.h b/livestatus/src/OringFilter.h
index 63d47b0..55214e6 100644
--- a/livestatus/src/OringFilter.h
+++ b/livestatus/src/OringFilter.h
@@ -47,6 +47,8 @@ public:
std::chrono::seconds timezone_offset) const override;
std::unique_ptr<Filter> copy() const override;
std::unique_ptr<Filter> negate() const override;
+ auto begin() const { return _subfilters.begin(); }
+ auto end() const { return _subfilters.end(); }
};
#endif // OringFilter_h
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index 379f5e4..37c9f97 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -50,7 +50,8 @@
#include "StringUtils.h"
#include "TableHosts.h"
#include "TableServices.h"
-class VariadicFilter;
+class AndingFilter;
+class OringFilter;
#ifdef CMC
#include "Host.h"
@@ -250,7 +251,8 @@ public:
mk::starts_with(column_name, std::string("service_"));
}
}
- void visit(const VariadicFilter & /*unused*/) override {}
+ void visit(const AndingFilter & /*unused*/) override {}
+ void visit(const OringFilter & /*unused*/) override {}
bool _value = true;
};
@@ -279,10 +281,9 @@ private:
} // namespace
void TableStateHistory::answerQuery(Query *query) {
- // Create a partial filter, that contains only such filters that
- // check attributes of current hosts and services
+ // Create a partial filter, that contains only such filters that check
+ // attributes of current hosts and services
std::deque<Filter *> object_filter;
-
if (core()->stateHistoryFilteringEnabled()) {
for (const auto &filter : *query->filter()) {
IsObjectFilter is_obj;
diff --git a/livestatus/src/VariadicFilter.h b/livestatus/src/VariadicFilter.h
index 6e2435d..b430734 100644
--- a/livestatus/src/VariadicFilter.h
+++ b/livestatus/src/VariadicFilter.h
@@ -35,8 +35,6 @@ public:
void addSubfilter(std::unique_ptr<Filter> f) {
_subfilters.push_back(std::move(f));
}
- auto begin() const { return _subfilters.begin(); }
- auto end() const { return _subfilters.end(); }
protected:
std::vector<std::unique_ptr<Filter>> _subfilters;