Module: check_mk
Branch: master
Commit: 929cde495898fa93e9ebf9be06664cec035ef8cd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=929cde495898fa…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Aug 10 10:01:23 2017 +0200
Const-corrected FilterVisitor.
Change-Id: I0c0cd665c1a50930cfa8e0619add00d05224afe8
---
livestatus/src/AttributeListAsIntColumn.cc | 3 ++-
livestatus/src/FilterVisitor.h | 6 +++---
livestatus/src/NegatingFilter.cc | 2 +-
livestatus/src/NegatingFilter.h | 2 +-
livestatus/src/TableStateHistory.cc | 6 +++---
livestatus/src/VariadicFilter.h | 6 +++---
6 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/livestatus/src/AttributeListAsIntColumn.cc
b/livestatus/src/AttributeListAsIntColumn.cc
index a445433..ae49337 100644
--- a/livestatus/src/AttributeListAsIntColumn.cc
+++ b/livestatus/src/AttributeListAsIntColumn.cc
@@ -40,7 +40,8 @@ unique_ptr<Filter> AttributeListAsIntColumn::createFilter(
this, relOp, AttributeListColumn::refValueFor(value, logger()));
}
-int32_t AttributeListAsIntColumn::getValue(Row row, contact * /*unused*/) const {
+int32_t AttributeListAsIntColumn::getValue(Row row,
+ contact * /*unused*/) const {
if (auto p = columnData<void>(row)) {
return static_cast<int32_t>(*offset_cast<unsigned long>(p,
_offset));
}
diff --git a/livestatus/src/FilterVisitor.h b/livestatus/src/FilterVisitor.h
index 50f2120..5704b6f 100644
--- a/livestatus/src/FilterVisitor.h
+++ b/livestatus/src/FilterVisitor.h
@@ -33,9 +33,9 @@ class VariadicFilter;
class FilterVisitor {
public:
virtual ~FilterVisitor() {}
- virtual void visit(ColumnFilter &) = 0;
- virtual void visit(NegatingFilter &) = 0;
- virtual void visit(VariadicFilter &) = 0;
+ virtual void visit(const ColumnFilter &) = 0;
+ virtual void visit(const NegatingFilter &) = 0;
+ virtual void visit(const VariadicFilter &) = 0;
};
#endif // FilterVisitor_h
diff --git a/livestatus/src/NegatingFilter.cc b/livestatus/src/NegatingFilter.cc
index cedab7b..d907d13 100644
--- a/livestatus/src/NegatingFilter.cc
+++ b/livestatus/src/NegatingFilter.cc
@@ -36,7 +36,7 @@ NegatingFilter::NegatingFilter(unique_ptr<Filter> filter)
void NegatingFilter::accept(FilterVisitor &v) { v.visit(*this); }
#ifdef CMC
-const unique_ptr<Filter> &NegatingFilter::subfilter() { return _filter; }
+const unique_ptr<Filter> &NegatingFilter::subfilter() const { return _filter;
}
#endif
bool NegatingFilter::accepts(Row row, contact *auth_user, int timezone_offset) {
diff --git a/livestatus/src/NegatingFilter.h b/livestatus/src/NegatingFilter.h
index 7127dee..e2bf808 100644
--- a/livestatus/src/NegatingFilter.h
+++ b/livestatus/src/NegatingFilter.h
@@ -42,7 +42,7 @@ public:
explicit NegatingFilter(std::unique_ptr<Filter> filter);
void accept(FilterVisitor &v) override;
bool accepts(Row row, contact *auth_user, int timezone_offset) override;
- const std::unique_ptr<Filter> &subfilter();
+ const std::unique_ptr<Filter> &subfilter() const;
private:
std::unique_ptr<Filter> _filter;
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index c636cf3..3d8868b 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -261,7 +261,7 @@ LogEntry *TableStateHistory::getNextLogentry() {
namespace {
class IsObjectFilter : public FilterVisitor {
public:
- void visit(ColumnFilter &f) override {
+ void visit(const ColumnFilter &f) override {
if (_value) {
auto column_name = f.column()->name();
_value = starts_with(column_name, string("current_")) ||
@@ -269,8 +269,8 @@ public:
starts_with(column_name, string("service_"));
}
}
- void visit(NegatingFilter & /*unused*/) override {}
- void visit(VariadicFilter & /*unused*/) override {}
+ void visit(const NegatingFilter & /*unused*/) override {}
+ void visit(const VariadicFilter & /*unused*/) override {}
bool _value = true;
};
diff --git a/livestatus/src/VariadicFilter.h b/livestatus/src/VariadicFilter.h
index a210363..1ab9f7e 100644
--- a/livestatus/src/VariadicFilter.h
+++ b/livestatus/src/VariadicFilter.h
@@ -42,9 +42,9 @@ public:
void addSubfilter(std::unique_ptr<Filter> f);
std::unique_ptr<Filter> stealLastSubfiler();
void combineFilters(int count, LogicalOperator andor);
- size_t size() { return _subfilters.size(); }
- auto begin() { return _subfilters.begin(); }
- auto end() { return _subfilters.end(); }
+ size_t size() const { return _subfilters.size(); }
+ auto begin() const { return _subfilters.begin(); }
+ auto end() const { return _subfilters.end(); }
void findIntLimits(const std::string &colum_nname, int *lower, int *upper,
int timezone_offset) const override;