.. _program_listing_file__tmp_ws_src_ecl_core_ecl_utilities_include_ecl_utilities_singleton.hpp: Program Listing for File singleton.hpp ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/ecl_core/ecl_utilities/include/ecl/utilities/singleton.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /***************************************************************************** ** Ifdefs *****************************************************************************/ #ifndef ECL_UTILITIES_SINGLETON_HPP_ #define ECL_UTILITIES_SINGLETON_HPP_ /***************************************************************************** ** Namespaces *****************************************************************************/ namespace ecl { /***************************************************************************** ** Class [Singleton] *****************************************************************************/ template 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_*/