Refactor the demo library.

This commit is contained in:
Gunnar Beutner 2013-09-25 09:39:31 +02:00
parent c3746e7c73
commit b3ff87b9dd
4 changed files with 15 additions and 15 deletions

View File

@ -10,8 +10,8 @@ CLEANFILES = \
$(top_builddir)/tools/mkembedconfig/mkembedconfig $< $@
libdemo_la_SOURCES = \
democomponent.cpp \
democomponent.h \
demo.cpp \
demo.h \
demo-type.conf
libdemo_la_CPPFLAGS = \

View File

@ -17,5 +17,5 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
type DemoComponent {
type Demo {
}

View File

@ -17,32 +17,32 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#include "demo/democomponent.h"
#include "demo/demo.h"
#include "base/dynamictype.h"
#include "base/logger_fwd.h"
#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga;
REGISTER_TYPE(DemoComponent);
REGISTER_TYPE(Demo);
/**
* Starts the component.
*/
void DemoComponent::Start(void)
void Demo::Start(void)
{
DynamicObject::Start();
m_DemoTimer = boost::make_shared<Timer>();
m_DemoTimer->SetInterval(5);
m_DemoTimer->OnTimerExpired.connect(boost::bind(&DemoComponent::DemoTimerHandler, this));
m_DemoTimer->OnTimerExpired.connect(boost::bind(&Demo::DemoTimerHandler, this));
m_DemoTimer->Start();
}
/**
* Stops the component.
*/
void DemoComponent::Stop(void)
void Demo::Stop(void)
{
/* Nothing to do here. */
}
@ -52,7 +52,7 @@ void DemoComponent::Stop(void)
*
* @param - Event arguments for the timer.
*/
void DemoComponent::DemoTimerHandler(void)
void Demo::DemoTimerHandler(void)
{
Log(LogInformation, "demo", "Hello World!");
}

View File

@ -17,8 +17,8 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
#ifndef DEMOCOMPONENT_H
#define DEMOCOMPONENT_H
#ifndef DEMO_H
#define DEMO_H
#include "base/dynamicobject.h"
#include "base/timer.h"
@ -29,11 +29,11 @@ namespace icinga
/**
* @ingroup demo
*/
class DemoComponent : public DynamicObject
class Demo : public DynamicObject
{
public:
DECLARE_PTR_TYPEDEFS(DemoComponent);
DECLARE_TYPENAME(DemoComponent);
DECLARE_PTR_TYPEDEFS(Demo);
DECLARE_TYPENAME(Demo);
virtual void Start(void);
virtual void Stop(void);
@ -46,4 +46,4 @@ private:
}
#endif /* DEMOCOMPONENT_H */
#endif /* DEMO_H */