summaryrefslogtreecommitdiff
path: root/graphs/cpp/singleton/singleton.hh
blob: 715a85f21a52ea383774dae0a628d3cc63822e81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// Created by martial.simon on 2/27/25.
//

#pragma once
#include <string>

template <typename T>
class Singleton
{
protected:
    Singleton() = default;

private:
    Singleton(const Singleton<T>&) = delete;
    Singleton& operator=(const Singleton<T>&) = delete;

public:
    static T& instance();
};

class Logger : public Singleton<Logger>
{
    Logger() = default;
    friend class Singleton<Logger>;

public:
    void open_log_file(const std::string& file);
    void write_to_log_file();
    void close_log_file();
};

#include "singleton.hxx"