Module: check_mk
Branch: master
Commit: c27b3313b7bb5d7a9725e77fe692ab33eed78456
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c27b3313b7bb5d…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jan 14 08:05:00 2016 +0100
Made TableServices::addColumns static and adapted call sites.
Now all TableFOO::addColumns methods are static, and this is much less
confusing: What they actually implement is a combination of delegating
constructors and multiple inheritance. Still not nice, but much clearer...
---
livestatus/src/TableDownComm.cc | 2 +-
livestatus/src/TableLog.cc | 2 +-
livestatus/src/TableServices.cc | 3 ++-
livestatus/src/TableServices.h | 2 +-
livestatus/src/TableStateHistory.cc | 2 +-
5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/livestatus/src/TableDownComm.cc b/livestatus/src/TableDownComm.cc
index 1d217d5..d08f4d4 100644
--- a/livestatus/src/TableDownComm.cc
+++ b/livestatus/src/TableDownComm.cc
@@ -93,7 +93,7 @@ TableDownComm::TableDownComm(bool is_downtime)
}
TableHosts::addColumns(this, "host_", (char *)&(ref->_host) -
(char *)ref);
- g_table_services->addColumns(this, "service_", (char
*)&(ref->_service) - (char *)ref, false /* no hosts table */);
+ TableServices::addColumns(this, "service_", (char *)&(ref->_service)
- (char *)ref, false /* no hosts table */);
}
TableDownComm::~TableDownComm()
diff --git a/livestatus/src/TableLog.cc b/livestatus/src/TableLog.cc
index 69b4871..2914ebe 100644
--- a/livestatus/src/TableLog.cc
+++ b/livestatus/src/TableLog.cc
@@ -105,7 +105,7 @@ void TableLog::addColumns(Table *table, string prefix, int
indirect_offset, bool
if (add_host)
TableHosts::addColumns(table, "current_host_", (char
*)&(ref->_host) - (char *)ref);
if (add_services)
- g_table_services->addColumns(table, "current_service_", (char
*)&(ref->_service) - (char *)ref, false /* no hosts table */);
+ TableServices::addColumns(table, "current_service_", (char
*)&(ref->_service) - (char *)ref, false /* no hosts table */);
TableContacts::addColumns(table, "current_contact_", (char
*)&(ref->_contact) - (char *)ref);
TableCommands::addColumns(table, "current_command_", (char
*)&(ref->_command) - (char *)ref);
}
diff --git a/livestatus/src/TableServices.cc b/livestatus/src/TableServices.cc
index 09360c2..7956182 100644
--- a/livestatus/src/TableServices.cc
+++ b/livestatus/src/TableServices.cc
@@ -207,6 +207,7 @@ TableServices::TableServices(bool by_group, bool by_hostgroup)
}
+// static
void TableServices::addColumns(Table *table, string prefix, int indirect_offset, bool
add_hosts)
{
/* es fehlt noch: double-Spalten, unsigned long spalten, etliche weniger wichtige
@@ -399,7 +400,7 @@ void TableServices::addColumns(Table *table, string prefix, int
indirect_offset,
"A list of all comments of the service with id, author, comment,
entry type and entry time", indirect_offset, false, true, true, true));
if (add_hosts)
- TableHosts::addColumns(this, "host_", (char *)(&svc.host_ptr) -
ref);
+ TableHosts::addColumns(table, "host_", (char *)(&svc.host_ptr) -
ref);
table->addColumn(new CustomVarsColumn(prefix + "custom_variable_names",
"A list of the names of all custom variables of the service",
(char *)(&svc.custom_variables) - ref, indirect_offset, CVT_VARNAMES));
diff --git a/livestatus/src/TableServices.h b/livestatus/src/TableServices.h
index ea49d6c..0f04854 100644
--- a/livestatus/src/TableServices.h
+++ b/livestatus/src/TableServices.h
@@ -46,7 +46,7 @@ public:
void *findObject(char *objectspec);
void add(service *svc);
void answerQuery(Query *);
- void addColumns(Table *, std::string prefix, int indirect_offset, bool add_hosts);
+ static void addColumns(Table *, std::string prefix, int indirect_offset, bool
add_hosts);
};
#endif // TableServices_h
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index 74b182f..f0cdf9e 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -155,7 +155,7 @@ void TableStateHistory::addColumns(Table *table)
// join host and service tables
TableHosts::addColumns(table, "current_host_", (char *)&(ref->_host)
- (char *)ref);
- g_table_services->addColumns(table, "current_service_", (char
*)&(ref->_service) - (char *)ref, false /* no hosts table */);
+ TableServices::addColumns(table, "current_service_", (char
*)&(ref->_service) - (char *)ref, false /* no hosts table */);
}
LogEntry *TableStateHistory::getPreviousLogentry()