/***************************************************************************
                           csingleton.h  -  description
                             -------------------
    begin                : Sun Jul 07 2002
    copyright            : (C) 2002 by Mathias Küster
    email                : mathen@ketelhot.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CSINGLETON_H
#define CSINGLETON_H

/**
  *@author Mathias Küster
  */

#include <stdio.h>
#include <dclib/dcos.h>

template<class type> class DLL_EXPORT CSingleton {
public:
	/** */
	virtual ~CSingleton();

	/** */
	static type * Instance();
protected:
	/** */
	CSingleton();

private:
	/** */
	static type * _instance_ptr;
};

template<class type> CSingleton<type>::CSingleton<type>()
{}

template<class type> CSingleton<type>::~CSingleton<type>()
{}

template<class type> type * CSingleton<type>::Instance()
{
	if( !_instance_ptr )
		_instance_ptr = new type;
	return _instance_ptr;
}

#endif
