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_
33 static T
* getInstance( intf_thread_t
*p_intf
= NULL
)
35 if ( m_instance
== NULL
)
36 m_instance
= new T( p_intf
);
40 static void killInstance()
42 if ( m_instance
!= NULL
)
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
>&);
61 T
* Singleton
<T
>::m_instance
= NULL
;
63 #endif // _SINGLETON_HPP_