1#pragma once
2
3#include "IDictionarySource.h"
4#include <Core/Block.h>
5
6#include <unordered_map>
7
8namespace Poco
9{
10namespace Util
11{
12 class AbstractConfiguration;
13}
14
15class Logger;
16}
17
18namespace DB
19{
20class Context;
21struct DictionaryStructure;
22
23/// creates IDictionarySource instance from config and DictionaryStructure
24class DictionarySourceFactory : private boost::noncopyable
25{
26public:
27 static DictionarySourceFactory & instance();
28
29 using Creator = std::function<DictionarySourcePtr(
30 const DictionaryStructure & dict_struct,
31 const Poco::Util::AbstractConfiguration & config,
32 const std::string & config_prefix,
33 Block & sample_block,
34 const Context & context,
35 bool check_config)>;
36
37 DictionarySourceFactory();
38
39 void registerSource(const std::string & source_type, Creator create_source);
40
41 DictionarySourcePtr create(
42 const std::string & name,
43 const Poco::Util::AbstractConfiguration & config,
44 const std::string & config_prefix,
45 const DictionaryStructure & dict_struct,
46 const Context & context,
47 bool check_config) const;
48
49private:
50 using SourceRegistry = std::unordered_map<std::string, Creator>;
51 SourceRegistry registered_sources;
52
53 Poco::Logger * log;
54};
55
56}
57