2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-03-15 11:19:52 +01:00
|
|
|
|
|
|
|
#ifndef SINGLETON_H
|
|
|
|
#define SINGLETON_H
|
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "base/i2-base.hpp"
|
2013-03-16 21:18:53 +01:00
|
|
|
#include <boost/thread/mutex.hpp>
|
|
|
|
|
2013-03-15 11:19:52 +01:00
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A singleton.
|
|
|
|
*
|
|
|
|
* @ingroup base
|
|
|
|
*/
|
|
|
|
template<typename T>
|
2013-03-18 22:40:40 +01:00
|
|
|
class Singleton
|
2013-03-15 11:19:52 +01:00
|
|
|
{
|
|
|
|
public:
|
2018-01-04 04:25:35 +01:00
|
|
|
static T *GetInstance()
|
2013-03-15 11:19:52 +01:00
|
|
|
{
|
2018-01-04 18:24:45 +01:00
|
|
|
static T instance;
|
|
|
|
return &instance;
|
2013-03-15 11:19:52 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* SINGLETON_H */
|