AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
resolvers.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-conf-export.hpp"
23
24#include <map>
25#include <functional>
26#include <string>
27#include <optional>
28#include <set>
29
30#include "conf/configuration.hpp"
31
32#include "singleton.hpp"
33
34
35namespace anch::conf {
36
47 using Resolver = std::function<std::optional<std::string>(const std::string& /*name*/,
48 const std::optional<std::string>& /*args*/)>;
49
60 class ANCH_CONF_EXPORT Resolvers: public anch::Singleton<Resolvers> {
61 friend class anch::conf::Configuration;
62 friend class anch::Singleton<Resolvers>;
63
64 // Attributes +
65 public:
67 static const std::string ENV;
68
70 static const std::string CONF;
71
73 static const std::string ARG;
74
75 private:
77 std::map<std::string, Resolver> _registry;
78
80 std::set<std::string> _protected;
81 // Attributes -
82
83 // Constructors +
84 private:
88 Resolvers();
89
90 public:
96 Resolvers(const Resolvers& resolvers) = delete;
97
103 Resolvers(Resolvers&& resolvers) = delete;
104 // Constructors -
105
106 // Destructor +
107 private:
111 virtual ~Resolvers();
112 // Destructor -
113
114 // Methods +
115 public:
126 Resolvers& registerResolver(Resolver resolver, const std::string& key);
127
137 Resolver getResolver(const std::string& key) const;
138
146 bool hasResolver(const std::string& key) const;
147 // Methods -
148
149 };
150
151}
152
153#include "conf/impl/resolvers.hpp"
Meyers' singleton implementation.
Definition singleton.hpp:50
Application configuration.
Definition configuration.hpp:45
static const std::string ENV
Definition resolvers.hpp:67
Resolvers(const Resolvers &resolvers)=delete
Resolvers(Resolvers &&resolvers)=delete
bool hasResolver(const std::string &key) const
static const std::string ARG
Definition resolvers.hpp:73
Resolver getResolver(const std::string &key) const
static const std::string CONF
Definition resolvers.hpp:70
Resolvers & registerResolver(Resolver resolver, const std::string &key)
AnCH configuration library namespace.
std::function< std::optional< std::string >(const std::string &, const std::optional< std::string > &)> Resolver
Definition resolvers.hpp:47