AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
resolvers.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 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 <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <map>
23#include <functional>
24#include <string>
25#include <optional>
26#include <set>
27
28#include "conf/configuration.hpp"
29
30#include "singleton.hpp"
31
32
33namespace anch::conf {
34
45 using Resolver = std::function<std::optional<std::string>(const std::string& /*name*/,
46 const std::optional<std::string>& /*args*/)>;
47
58 class Resolvers: public anch::Singleton<Resolvers> {
61
62 // Attributes +
63 public:
65 static const std::string ENV;
66
68 static const std::string CONF;
69
71 static const std::string ARG;
72
73 private:
75 std::map<std::string, Resolver> _registry;
76
78 std::set<std::string> _protected;
79 // Attributes -
80
81 // Constructors +
82 private:
86 Resolvers();
87
88 public:
94 Resolvers(const Resolvers& resolvers) = delete;
95
101 Resolvers(Resolvers&& resolvers) = delete;
102 // Constructors -
103
104 // Destructor +
105 private:
109 virtual ~Resolvers();
110 // Destructor -
111
112 // Methods +
113 public:
124 Resolvers& registerResolver(Resolver resolver, const std::string& key);
125
135 Resolver getResolver(const std::string& key) const;
136
144 bool hasResolver(const std::string& key) const;
145 // Methods -
146
147 };
148
149}
150
151#include "conf/impl/resolvers.hpp"
Meyers' singleton implementation.
Definition singleton.hpp:34
Application configuration.
Definition configuration.hpp:43
static const std::string ENV
Definition resolvers.hpp:65
Resolvers(const Resolvers &resolvers)=delete
Resolvers(Resolvers &&resolvers)=delete
bool hasResolver(const std::string &key) const
static const std::string ARG
Definition resolvers.hpp:71
Resolver getResolver(const std::string &key) const
static const std::string CONF
Definition resolvers.hpp:68
Resolvers & registerResolver(Resolver resolver, const std::string &key)