<commit_before>#ifndef H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_SINGLETON_HPP
#define H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_SINGLETON_HPP

#include "NonCopyable.hpp"
#include "NonMovable.hpp"
#include "internal/common.hpp"
#include "internal/singleton.hpp"

#include <functional>
#include <memory>

namespace cutehmi {

/**
 * %Singleton template. It may be necessary to make derived class a friend of inheriting class to grant Singleton<C> access to its
 * constructor.
 */
template <class C>
class Singleton:
	public NonCopyable,
	public NonMovable
{
	public:
		/**
		 * Get instance. Returns a reference to the instance of the singleton class. Object is instantiated upon first call of this
		 * function.
		 * @return a reference to the instance of the singleton class.
		 *
		 * @warning because this class can be inherited by QObject, destroySingletonInstances() function should be used by front-end
		 * application to satisfy the requirement that QApplication has to be first created and last destroyed QObject.
		 *
		 * @warning if neither Destroy() function nor destroySingletonInstances() has been used, then destructor will be called on
		 * static de-initialization. Beware of using singleton instance in destructor of some other static object. If that's
		 * unavoidable, assure that singletons or any static objects are constructed in the reverse order they are going to be
		 * destructed.
		 */
		static C & Instance();

		/**
		 * Destroy instance. This function is provided to satisfy the requirement that QApplication has to be first created and last
		 * destroyed QObject. Once this function is called singleton becomes unusable.
		 *
		 * @note Only frontend applications, which instantiate QApplication should take care about this function.
		 *
		 * @note Typically it is better to use destroySingletonInstances() function, which destroys all singletons, that inherit
		 * after this class, at once.
		 *
		 * @assumption{cutehmi::Singleton-singleton_class_will_not_call_Destroy_from_destructor}
		 * Singleton class can not call Destroy() functions from its destructor (neither its own nor of another class).
		 *
		 * @see destroySingletonInstances().
		 */
		static void Destroy();

	protected:
		// shield the constructor and destructor to prevent outside sources
		// from creating or destroying a Singleton instance.
	
		/**
		 * Default constructor.
		 */
		Singleton();
	
		/**
		 * Destructor.
		 */<commit_msg>Improve documentation.<commit_after>#ifndef H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_SINGLETON_HPP
#define H_EXTENSIONS_CUTEHMI_2_INCLUDE_CUTEHMI_SINGLETON_HPP

#include "NonCopyable.hpp"
#include "NonMovable.hpp"
#include "internal/common.hpp"
#include "internal/singleton.hpp"

#include <functional>
#include <memory>

namespace cutehmi {

/**
 * %Singleton template. It may be necessary to make derived class a friend of inheriting class to grant Singleton<C> access to its
 * constructor.
 */
template <class C>
class Singleton:
	public NonCopyable,
	public NonMovable
{
	public:
		/**
		 * Get instance. Returns a reference to the instance of the singleton class. Object is instantiated upon first call of this
		 * function.
		 * @return a reference to the instance of the singleton class.
		 *
		 * @warning because this class can be inherited by QObject, destroySingletonInstances() function should be used by front-end
		 * application to satisfy the requirement that QApplication has to be first created and last destroyed QObject.
		 *
		 * @warning if neither Destroy() function nor destroySingletonInstances() has been used, then destructor will be called on
		 * static de-initialization. Beware of using singleton instance in destructor of some other static object. If that's
		 * unavoidable, assure that singletons or any static objects are constructed in the reverse order they are going to be
		 * destructed.
		 */
		static C & Instance();

		/**
		 * Destroy instance. This function is provided to satisfy the requirement that QApplication has to be first created and last
		 * destroyed QObject. Once this function is called singleton becomes unusable.
		 *
		 * @note Only frontend applications, which instantiate QApplication should take care about this function.
		 *
		 * @note Typically it is better to use destroySingletonInstances() function, which destroys all singletons, that inherit
		 * after this class, at once.
		 *
		 * @assumption{cutehmi::Singleton-singleton_class_will_not_call_Destroy_from_destructor}
		 * Class that inherits after Singleton will not call Destroy() functions from its destructor (neither its own nor of another
		 * class).
		 *
		 * @see destroySingletonInstances().
		 */
		static void Destroy();

	protected:
		// shield the constructor and destructor to prevent outside sources
		// from creating or destroying a Singleton instance.
	
		/**
		 * Default constructor.
		 */
		Singleton();
	
		/**
		 * Destructor.
		 */
{'fraction_non_alphanumeric': 0.06619289340101522, 'fraction_numerical': 0.0008121827411167512, 'mean_word_length': 4.078350515463917, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6534695', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1264, 'n_words': 552}