ClickHouse/dbms/src/Dictionaries/DictionarySourceFactory.h

51 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <Dictionaries/IDictionarySource.h>
#include <ext/singleton.h>
2016-01-12 02:21:15 +00:00
#include <unordered_map>
2016-12-08 02:49:04 +00:00
namespace Poco
{
namespace Util
{
class AbstractConfiguration;
}
class Logger;
}
2016-12-08 02:49:04 +00:00
namespace DB
{
class Context;
2016-12-12 06:02:35 +00:00
struct DictionaryStructure;
/// creates IDictionarySource instance from config and DictionaryStructure
class DictionarySourceFactory : public ext::singleton<DictionarySourceFactory>
{
public:
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)>;
DictionarySourceFactory();
void registerSource(const std::string & source_type, Creator create_source);
DictionarySourcePtr create(
const std::string & name, const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix,
const DictionaryStructure & dict_struct, Context & context) const;
private:
using TSourceRegistry = std::unordered_map<std::string, Creator>;
TSourceRegistry registered_sources;
Poco::Logger * log;
};
}