From 3cfccba1ea53fd7856850054758728ac84853cfa Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 4 Nov 2013 15:57:46 +0100 Subject: [PATCH] Implement "hello world" test app. Refs #4995 --- lib/CMakeLists.txt | 1 + lib/base/application.cpp | 5 +++++ lib/base/application.h | 2 +- lib/hello/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++ lib/hello/hello-type.conf | 21 +++++++++++++++++++ lib/hello/hello.cpp | 38 +++++++++++++++++++++++++++++++++ lib/hello/hello.h | 44 +++++++++++++++++++++++++++++++++++++++ lib/hello/hello.ti | 10 +++++++++ 8 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 lib/hello/CMakeLists.txt create mode 100644 lib/hello/hello-type.conf create mode 100644 lib/hello/hello.cpp create mode 100644 lib/hello/hello.h create mode 100644 lib/hello/hello.ti diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 358be7d3b..f4706e600 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -20,3 +20,4 @@ add_subdirectory(config) add_subdirectory(icinga) add_subdirectory(db_ido) add_subdirectory(methods) +add_subdirectory(hello) diff --git a/lib/base/application.cpp b/lib/base/application.cpp index b1996c4c9..5128a0445 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -159,6 +159,11 @@ void Application::RunEventLoop(void) const #endif /* _DEBUG */ } +void Application::OnShutdown(void) +{ + /* Nothing to do here. */ +} + /** * Watches for changes to the system time. Adjusts timers if necessary. */ diff --git a/lib/base/application.h b/lib/base/application.h index 518105ce6..7f6c483a5 100644 --- a/lib/base/application.h +++ b/lib/base/application.h @@ -101,7 +101,7 @@ protected: void RunEventLoop(void) const; - virtual void OnShutdown(void) = 0; + virtual void OnShutdown(void); private: static Application *m_Instance; /**< The application instance. */ diff --git a/lib/hello/CMakeLists.txt b/lib/hello/CMakeLists.txt new file mode 100644 index 000000000..e1e6e6cb5 --- /dev/null +++ b/lib/hello/CMakeLists.txt @@ -0,0 +1,40 @@ +# Icinga 2 +# Copyright (C) 2012-2013 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. + +mkclass_target(hello.ti hello.th) + +mkembedconfig_target(hello-type.conf hello-type.cpp) + +add_library(hello SHARED + hello.cpp hello.th hello-type.cpp +) + +target_link_libraries(hello ${Boost_LIBRARIES} base) + +set_target_properties ( + hello PROPERTIES + INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 + FOLDER Lib +) + +install( + TARGETS hello + RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2 +) + + diff --git a/lib/hello/hello-type.conf b/lib/hello/hello-type.conf new file mode 100644 index 000000000..b6c682d9f --- /dev/null +++ b/lib/hello/hello-type.conf @@ -0,0 +1,21 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2013 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. * + ******************************************************************************/ + +type Hello { +} diff --git a/lib/hello/hello.cpp b/lib/hello/hello.cpp new file mode 100644 index 000000000..7b483e431 --- /dev/null +++ b/lib/hello/hello.cpp @@ -0,0 +1,38 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2013 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 "hello/hello.h" +#include "base/dynamictype.h" +#include "base/logger_fwd.h" + +using namespace icinga; + +REGISTER_TYPE(Hello); + +/** + * The entry point for the Hello application. + * + * @returns An exit status. + */ +int Hello::Main(void) +{ + Log(LogInformation, "hello", "Hello World!"); + + return 0; +} diff --git a/lib/hello/hello.h b/lib/hello/hello.h new file mode 100644 index 000000000..fa187c09b --- /dev/null +++ b/lib/hello/hello.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2013 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 HELLO_H +#define HELLO_H + +#include "hello/hello.th" + +namespace icinga +{ + +/** + * The Hello application. + * + * @ingroup hello + */ +class Hello : public ReflectionObjectImpl +{ +public: + DECLARE_PTR_TYPEDEFS(Hello); + DECLARE_TYPENAME(Hello); + + int Main(void); +}; + +} + +#endif /* HELLO_H */ diff --git a/lib/hello/hello.ti b/lib/hello/hello.ti new file mode 100644 index 000000000..f72265501 --- /dev/null +++ b/lib/hello/hello.ti @@ -0,0 +1,10 @@ +#include "base/application.h" + +namespace icinga +{ + +class Hello : Application +{ +}; + +} -- 2.40.0