//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/Models/ISingleton.h
//! @brief     Defines the standard mix-in ISingleton.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_GUI_MODELS_ISINGLETON_H
#define BORNAGAIN_GUI_MODELS_ISINGLETON_H

//! Base class for singletons.
//! @ingroup tools_internal

template <class T> class ISingleton {
public:
    static T& instance()
    {
        static T m_instance;
        return m_instance;
    }

    ISingleton(const ISingleton&) = delete;
    ISingleton& operator=(const ISingleton&) = delete;
    ISingleton(ISingleton&&) = delete;
    ISingleton& operator=(ISingleton&&) = delete;
    
protected:
    ISingleton() = default;
    ~ISingleton() = default;
};

#endif // BORNAGAIN_GUI_MODELS_ISINGLETON_H