2015-01-26 15:27:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Dictionaries/IDictionarySource.h>
|
2017-07-10 04:34:14 +00:00
|
|
|
#include <ext/singleton.h>
|
2016-01-12 02:21:15 +00:00
|
|
|
|
2017-11-27 17:34:43 +00:00
|
|
|
#include <unordered_map>
|
2015-01-26 15:27:51 +00:00
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
namespace Poco
|
2015-01-26 15:27:51 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
2017-11-27 17:34:43 +00:00
|
|
|
|
|
|
|
class Logger;
|
2015-01-26 15:27:51 +00:00
|
|
|
}
|
|
|
|
|
2016-12-08 02:49:04 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
2016-12-12 06:02:35 +00:00
|
|
|
struct DictionaryStructure;
|
2015-01-26 15:27:51 +00:00
|
|
|
|
2015-02-10 14:50:43 +00:00
|
|
|
/// creates IDictionarySource instance from config and DictionaryStructure
|
2017-07-10 04:34:14 +00:00
|
|
|
class DictionarySourceFactory : public ext::singleton<DictionarySourceFactory>
|
2015-01-26 15:27:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-11-27 17:34:43 +00:00
|
|
|
using Creator = std::function<DictionarySourcePtr(
|
|
|
|
const DictionaryStructure & dict_struct,
|
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const std::string & config_prefix,
|
|
|
|
Block & sample_block,
|
|
|
|
const Context & context)>;
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
DictionarySourceFactory();
|
2016-04-10 10:24:07 +00:00
|
|
|
|
2017-11-27 17:34:43 +00:00
|
|
|
void registerSource(const std::string & source_type, Creator create_source);
|
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
DictionarySourcePtr create(
|
2017-10-06 10:31:06 +00:00
|
|
|
const std::string & name, const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix,
|
2017-04-01 07:20:54 +00:00
|
|
|
const DictionaryStructure & dict_struct, Context & context) const;
|
2017-11-27 17:34:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
using TSourceRegistry = std::unordered_map<std::string, Creator>;
|
|
|
|
TSourceRegistry registered_sources;
|
|
|
|
|
|
|
|
Poco::Logger * log;
|
2015-01-26 15:27:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|