Module: check_mk
Branch: master
Commit: 0ee4434201b1e4c3f08cbf8a59d75119a91ea604
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0ee4434201b1e4…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jan 14 14:47:41 2016 +0100
Add a possible 3rd level of indirection to Column and thread it through to
AttributelistColumn.
This is needed for the chain:
bygroup => Service => Host => State
Things are getting slightly out of hands here... :-/ What we really need is
a kind of flexible DSL for describing the access path instead of this
monster.
---
livestatus/src/AttributelistColumn.h | 4 ++--
livestatus/src/Column.cc | 18 ++++++++----------
livestatus/src/Column.h | 3 ++-
livestatus/src/IntColumn.h | 4 ++--
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/livestatus/src/AttributelistColumn.h b/livestatus/src/AttributelistColumn.h
index bb0be54..f6ff767 100644
--- a/livestatus/src/AttributelistColumn.h
+++ b/livestatus/src/AttributelistColumn.h
@@ -46,8 +46,8 @@ class AttributelistColumn : public IntColumn {
public:
AttributelistColumn(std::string name, std::string description, int offset,
int indirect_offset, bool show_list,
- int extra_offset = -1)
- : IntColumn(name, description, indirect_offset, extra_offset)
+ int extra_offset = -1, int extra_extra_offset = -1)
+ : IntColumn(name, description, indirect_offset, extra_offset,
extra_extra_offset)
, _offset(offset)
, _show_list(show_list)
{
diff --git a/livestatus/src/Column.cc b/livestatus/src/Column.cc
index 354b784..ce72c22 100644
--- a/livestatus/src/Column.cc
+++ b/livestatus/src/Column.cc
@@ -28,31 +28,29 @@ using std::string;
Column::Column(string name, string description, int indirect_offset,
- int extra_offset)
+ int extra_offset, int extra_extra_offset)
: _name(name)
, _description(description)
, _indirect_offset(indirect_offset)
, _extra_offset(extra_offset)
+ , _extra_extra_offset(extra_extra_offset)
{
}
void *Column::shiftPointer(void *data)
{
- if (!data)
- return 0;
-
+ if (!data) return 0;
if (_indirect_offset >= 0) {
- // add one indirection level
- // indirect_offset is place in structure, where
- // pointer to real object is
data = *((void **)((char *)data + _indirect_offset));
- if (!data)
- return 0;
}
- // one optional extra level of indirection
+ if (!data) return 0;
if (_extra_offset >= 0)
data = *((void **)((char *)data + _extra_offset));
+ if (!data) return 0;
+ if (_extra_extra_offset >= 0)
+ data = *((void **)((char *)data + _extra_extra_offset));
+
return data;
}
diff --git a/livestatus/src/Column.h b/livestatus/src/Column.h
index e5a1f47..c56e0bd 100644
--- a/livestatus/src/Column.h
+++ b/livestatus/src/Column.h
@@ -47,10 +47,11 @@ class Column
std::string _description;
int _indirect_offset;
int _extra_offset;
+ int _extra_extra_offset;
public:
Column(std::string name, std::string description, int indirect_offset,
- int extra_offset);
+ int extra_offset, int extra_extra_offset = -1);
virtual ~Column() {}
const char *name() const { return _name.c_str(); }
diff --git a/livestatus/src/IntColumn.h b/livestatus/src/IntColumn.h
index 3eb50bd..c002db2 100644
--- a/livestatus/src/IntColumn.h
+++ b/livestatus/src/IntColumn.h
@@ -36,8 +36,8 @@ class Query;
class IntColumn : public Column {
public:
IntColumn(std::string name, std::string description, int indirect_offset,
- int extra_offset)
- : Column(name, description, indirect_offset, extra_offset)
+ int extra_offset, int extra_extra_offset = -1)
+ : Column(name, description, indirect_offset, extra_offset, extra_extra_offset)
{
}
virtual int32_t getValue(void *data, Query *) = 0;