1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "livestatus/column.hpp"
7 #include "base/object.hpp"
8 #include "base/dictionary.hpp"
9 #include "base/array.hpp"
15 struct LivestatusRowValue {
17 LivestatusGroupByType GroupByType;
21 typedef std::function<bool (const Value&, LivestatusGroupByType, const Object::Ptr&)> AddRowFunction;
28 class Table : public Object
31 DECLARE_PTR_TYPEDEFS(Table);
33 static Table::Ptr GetByName(const String& name, const String& compat_log_path = "", const unsigned long& from = 0, const unsigned long& until = 0);
35 virtual String GetName() const = 0;
36 virtual String GetPrefix() const = 0;
38 std::vector<LivestatusRowValue> FilterRows(const intrusive_ptr<Filter>& filter, int limit = -1);
40 void AddColumn(const String& name, const Column& column);
41 Column GetColumn(const String& name) const;
42 std::vector<String> GetColumnNames() const;
44 LivestatusGroupByType GetGroupByType() const;
47 Table(LivestatusGroupByType type = LivestatusGroupByNone);
49 virtual void FetchRows(const AddRowFunction& addRowFn) = 0;
51 static Value ZeroAccessor(const Value&);
52 static Value OneAccessor(const Value&);
53 static Value EmptyStringAccessor(const Value&);
54 static Value EmptyArrayAccessor(const Value&);
55 static Value EmptyDictionaryAccessor(const Value&);
57 LivestatusGroupByType m_GroupByType;
58 Value m_GroupByObject;
61 std::map<String, Column> m_Columns;
63 bool FilteredAddRow(std::vector<LivestatusRowValue>& rs, const intrusive_ptr<Filter>& filter, int limit, const Value& row, LivestatusGroupByType groupByType, const Object::Ptr& groupByObject);
70 #include "livestatus/filter.hpp"