// singleton.tcc - Copyright 2005, 2006, University
//               of Padova, dept. of Pure and Applied
//               Mathematics
//
// 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

#ifndef SINGLETON_TCC
#define SINGLETON_TCC 1

#include <sgpemv2/templates/singleton.hh>

template<typename Instantiated_class>
Instantiated_class*
sgpem::Singleton<Instantiated_class>::_instance = NULL;

template<typename Instantiated_class>
Glib::RecMutex
sgpem::Singleton<Instantiated_class>::_mutex;


template<typename Instantiated_class>
Instantiated_class&
sgpem::Singleton<Instantiated_class>::get_instance()
{
  Glib::RecMutex::Lock lock (_mutex);
  if (_instance == NULL)
    _instance = new Instantiated_class();
  return *_instance;
}


#endif //~ SINGLETON_TCC

