icinga2/lib/base/singleton.hpp

30 lines
333 B
C++
Raw Permalink Normal View History

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