AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
writerRegistry.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-log-export.hpp"
23
24#include <map>
25#include <set>
26#include <functional>
27
28#include "singleton.hpp"
29#include "log/writer.hpp"
30
31
32namespace anch::log {
33
43 using CreateWriter = std::function<anch::log::Writer*(bool, bool, const anch::conf::Section&)>;
44
54 class ANCH_LOG_EXPORT WriterRegistry: public anch::Singleton<WriterRegistry> {
55 friend class anch::Singleton<WriterRegistry>;
56
57 // Attributes +
58 private:
60 std::map<std::string, anch::log::CreateWriter> _registry;
61
63 std::map<std::string, anch::log::Writer*> _writers;
64 // Attributes -
65
66 // Constructors +
67 private:
71 WriterRegistry();
72
73 public:
79 WriterRegistry(const WriterRegistry& other) = delete;
80
86 WriterRegistry(WriterRegistry&& other) = delete;
87 // Constructors -
88
89 // Destructor +
90 private:
94 virtual ~WriterRegistry();
95 // Destructor -
96
97 // Methods +
98 public:
105 void registerWriter(const std::string& name, const anch::log::CreateWriter& writerBuilder);
106
114 bool contains(const std::string& name) const;
115
126 anch::log::Writer* create(const std::string& name,
127 bool threadSafe,
128 bool lowPriority,
129 const anch::conf::Section& section);
130 // Methods -
131
132 };
133
134}
135
136#include "log/impl/writerRegistry.hpp"
Meyers' singleton implementation.
Definition singleton.hpp:50
Logger writter definition.
Definition writer.hpp:40
WriterRegistry(WriterRegistry &&other)=delete
void registerWriter(const std::string &name, const anch::log::CreateWriter &writerBuilder)
anch::log::Writer * create(const std::string &name, bool threadSafe, bool lowPriority, const anch::conf::Section &section)
bool contains(const std::string &name) const
WriterRegistry(const WriterRegistry &other)=delete
anch::ini::Section Section
Definition section.hpp:27
AnCH logging library namespace.
Definition constants.hpp:26
std::function< anch::log::Writer *(bool, bool, const anch::conf::Section &)> CreateWriter
Definition writerRegistry.hpp:43