Commit 7c0d54a5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Remove QSingleton class

parent 57b2d95a
......@@ -51,7 +51,6 @@ SET(VLMC_SRCS
Settings/SettingValue.cpp
Tools/ErrorHandler.cpp
Tools/MemoryPool.hpp
Tools/QSingleton.hpp
Tools/RendererEventWatcher.cpp
Tools/Singleton.hpp
Tools/Toggleable.hpp
......
......@@ -24,7 +24,6 @@
#ifndef ABOUT_H
#define ABOUT_H
#include "Tools/QSingleton.hpp"
#include "ui_About.h"
#include <QDialog>
......
/*****************************************************************************
* QSingleton.hpp : Generic singleton pattern implementation with Qt parent's
* parameter that can be passed to the ctor
*****************************************************************************
* Copyright (C) 2008-2014 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/** \file
* This file contain the templated singleton.
* Class/struct to be singletonized just have to
* iherit from this classe with the class/struct type in template
* parameter.You have to do few other things, but you know your job,
* don't you? :)
*/
#ifndef QSINGLETON_HPP
#define QSINGLETON_HPP
#include <stdlib.h>
#include <QWidget>
template <typename T>
class QSingleton
{
public:
static T* getInstance( QWidget* parent = NULL )
{
if ( m_instance == NULL )
m_instance = new T( parent );
return m_instance;
}
static void destroyInstance()
{
if ( m_instance != NULL )
{
delete m_instance;
m_instance = NULL;
}
}
protected:
QSingleton(){}
virtual ~QSingleton(){}
//Not implemented since these methods should *NEVER* been called. If they do, it probably won't compile :)
QSingleton(const QSingleton<T>&);
QSingleton<T>& operator=(const QSingleton<T>&);
private:
static T* m_instance;
};
template <typename T>
T* QSingleton<T>::m_instance = NULL;
#endif // QSINGLETON_HPP
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment