Program Listing for File singleton.hpp

Return to documentation for file (/tmp/ws/src/ecl_core/ecl_utilities/include/ecl/utilities/singleton.hpp)

/*****************************************************************************
** Ifdefs
*****************************************************************************/

#ifndef ECL_UTILITIES_SINGLETON_HPP_
#define ECL_UTILITIES_SINGLETON_HPP_

/*****************************************************************************
** Namespaces
*****************************************************************************/

namespace ecl {

/*****************************************************************************
** Class [Singleton]
*****************************************************************************/
template<typename T> class Singleton
{
  public:
    static T& instance()
    {
        static T the_single_instance;  // assumes T has a protected default constructor
        return the_single_instance;
    }

    virtual ~Singleton () {}
};

} // namespace ecl

#endif /*ECL_UTILITIES_SINGLETON_HPP_*/