Qt: respect font sizes
[vlc.git] / modules / gui / qt4 / util / singleton.hpp
blobf6f6050d624f57e718cec6aa80a10f2665be3666
1 /*****************************************************************************
2 * singleton.hpp: Generic Singleton pattern implementation
3 ****************************************************************************
4 * Copyright (C) 2009 VideoLAN
6 * Authors: Hugo Beauzee-Luyssen <beauze.h # gmail - com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifndef _SINGLETON_HPP_
24 #define _SINGLETON_HPP_
26 #include <stdlib.h>
27 #include "qt4.hpp"
29 template <typename T>
30 class Singleton
32 public:
33 static T* getInstance( intf_thread_t *p_intf = NULL )
35 if ( m_instance == NULL )
36 m_instance = new T( p_intf );
37 return m_instance;
40 static void killInstance()
42 if ( m_instance != NULL )
44 delete m_instance;
45 m_instance = NULL;
48 protected:
49 Singleton(){}
50 virtual ~Singleton(){}
51 /* Not implemented since these methods should *NEVER* been called.
52 If they do, it probably won't compile :) */
53 Singleton(const Singleton<T>&);
54 Singleton<T>& operator=(const Singleton<T>&);
56 private:
57 static T* m_instance;
60 template <typename T>
61 T* Singleton<T>::m_instance = NULL;
63 #endif // _SINGLETON_HPP_