/*
 * Copyright (c) 1999 Johnny C. Lam.
 * All rights reserved.
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  The author makes no representations
 * about the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 */

template <class Doomed>
inline
SingletonDestroyer<Doomed>::SingletonDestroyer(Doomed *d)
    : _doomed(d)
{}

template <class Doomed>
inline
SingletonDestroyer<Doomed>::~SingletonDestroyer()
{
    delete _doomed;
}

template <class Doomed>
inline
void
SingletonDestroyer<Doomed>::SetDoomed(Doomed *d)
{
    _doomed = d;
}

template <class T>
inline
T *
Singleton<T>::Instance() {
    if (!_instance) {
	_instance = new T;
	_destroyer.SetDoomed(_instance);
    }
    return _instance;
}

// Local Variables:
// mode:C++
// End:
