]> granicus.if.org Git - icinga2/blob - lib/base/singleton.hpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / base / singleton.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef SINGLETON_H
4 #define SINGLETON_H
5
6 #include "base/i2-base.hpp"
7 #include <boost/thread/mutex.hpp>
8
9 namespace icinga
10 {
11
12 /**
13  * A singleton.
14  *
15  * @ingroup base
16  */
17 template<typename T>
18 class Singleton
19 {
20 public:
21         static T *GetInstance()
22         {
23                 static T instance;
24                 return &instance;
25         }
26 };
27
28 }
29
30 #endif /* SINGLETON_H */