icinga2/components/demo/democomponent.cpp

59 lines
2.2 KiB
C++
Raw Normal View History

/******************************************************************************
* 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 *
2012-05-11 13:33:57 +02:00
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
2013-03-17 20:19:29 +01:00
#include "demo/democomponent.h"
2013-03-16 21:18:53 +01:00
#include "base/dynamictype.h"
#include "base/logger_fwd.h"
#include <boost/smart_ptr/make_shared.hpp>
2012-04-23 13:45:41 +02:00
using namespace icinga;
REGISTER_TYPE(DemoComponent);
/**
* Starts the component.
*/
2012-04-23 13:45:41 +02:00
void DemoComponent::Start(void)
{
DynamicObject::Start();
2012-04-23 13:45:41 +02:00
2012-06-15 19:32:41 +02:00
m_DemoTimer = boost::make_shared<Timer>();
m_DemoTimer->SetInterval(5);
2012-06-15 19:32:41 +02:00
m_DemoTimer->OnTimerExpired.connect(boost::bind(&DemoComponent::DemoTimerHandler, this));
2012-04-23 13:45:41 +02:00
m_DemoTimer->Start();
}
/**
* Stops the component.
*/
2012-04-23 13:45:41 +02:00
void DemoComponent::Stop(void)
{
/* Nothing to do here. */
2012-04-23 13:45:41 +02:00
}
/**
* Periodically sends a demo::HelloWorld message.
*
2012-05-10 13:46:04 +02:00
* @param - Event arguments for the timer.
*/
2012-06-15 19:32:41 +02:00
void DemoComponent::DemoTimerHandler(void)
2012-04-23 13:45:41 +02:00
{
Log(LogInformation, "demo", "Hello World!");
2012-04-23 13:45:41 +02:00
}