servicestable.h \
statustable.cpp \
statustable.h \
+ timeperiodstable.cpp \
+ timeperiodstable.h \
table.cpp \
table.h
<ClInclude Include="servicegroupsstable.h" />
<ClInclude Include="servicestable.h" />
<ClInclude Include="statustable.h" />
+ <ClInclude Include="timeperiodstable.h" />
<ClInclude Include="logtable.h" />
<ClInclude Include="table.h" />
</ItemGroup>
<ClCompile Include="servicegroupstable.cpp" />
<ClCompile Include="servicestable.cpp" />
<ClCompile Include="statustable.cpp" />
+ <ClCompile Include="timeperiodstable.cpp" />
<ClCompile Include="logtable.cpp" />
<ClCompile Include="table.cpp" />
</ItemGroup>
<ClInclude Include="statustable.h">
<Filter>Headerdateien</Filter>
</ClInclude>
+ <ClInclude Include="timeperiodstable.h">
+ <Filter>Headerdateien</Filter>
+ </ClInclude>
<ClInclude Include="logtable.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClCompile Include="statustable.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
+ <ClCompile Include="timeperiodstable.cpp">
+ <Filter>Quelldateien</Filter>
+ </ClCompile>
<ClCompile Include="logtable.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
#include "livestatus/commandstable.h"
#include "livestatus/commentstable.h"
#include "livestatus/downtimestable.h"
+#include "livestatus/timeperiodstable.h"
#include "livestatus/logtable.h"
#include "livestatus/filter.h"
#include "base/array.h"
return boost::make_shared<CommentsTable>();
else if (name == "downtimes")
return boost::make_shared<DowntimesTable>();
+ else if (name == "timeperiods")
+ return boost::make_shared<TimePeriodsTable>();
else if (name == "log")
return boost::make_shared<LogTable>();
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software Foundation *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ******************************************************************************/
+
+#include "livestatus/timeperiodstable.h"
+#include "icinga/icingaapplication.h"
+#include "icinga/timeperiod.h"
+#include "base/dynamictype.h"
+#include "base/objectlock.h"
+#include "base/convert.h"
+#include <boost/foreach.hpp>
+#include <boost/algorithm/string/replace.hpp>
+
+using namespace icinga;
+using namespace livestatus;
+
+TimePeriodsTable::TimePeriodsTable(void)
+{
+ AddColumns(this);
+}
+
+void TimePeriodsTable::AddColumns(Table *table, const String& prefix,
+ const Column::ObjectAccessor& objectAccessor)
+{
+ table->AddColumn(prefix + "name", Column(&TimePeriodsTable::NameAccessor, objectAccessor));
+ table->AddColumn(prefix + "alias", Column(&TimePeriodsTable::AliasAccessor, objectAccessor));
+}
+
+String TimePeriodsTable::GetName(void) const
+{
+ return "timeperiod";
+}
+
+void TimePeriodsTable::FetchRows(const AddRowFunction& addRowFn)
+{
+ BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("TimePeriod")) {
+ addRowFn(object);
+ }
+}
+
+Value TimePeriodsTable::NameAccessor(const Value& row)
+{
+ return static_cast<TimePeriod::Ptr>(row)->GetName();
+}
+
+Value TimePeriodsTable::AliasAccessor(const Value& row)
+{
+ /* TODO GetDisplayName() ? */
+ return static_cast<TimePeriod::Ptr>(row)->GetName();
+}
+
--- /dev/null
+/******************************************************************************
+ * Icinga 2 *
+ * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software Foundation *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ******************************************************************************/
+
+#ifndef TIMEPERIODSTABLE_H
+#define TIMEPERIODSTABLE_H
+
+#include "livestatus/table.h"
+
+using namespace icinga;
+
+namespace livestatus
+{
+
+/**
+ * @ingroup livestatus
+ */
+class TimePeriodsTable : public Table
+{
+public:
+ DECLARE_PTR_TYPEDEFS(TimePeriodsTable);
+
+ TimePeriodsTable(void);
+
+ static void AddColumns(Table *table, const String& prefix = String(),
+ const Column::ObjectAccessor& objectAccessor = Column::ObjectAccessor());
+
+ virtual String GetName(void) const;
+
+protected:
+ virtual void FetchRows(const AddRowFunction& addRowFn);
+
+ static Value NameAccessor(const Value& row);
+ static Value AliasAccessor(const Value& row);
+};
+
+}
+
+#endif /* TIMEPERIODSTABLE_H */