ClickHouse/dbms/Disks/DiskFactory.h

44 lines
964 B
C++
Raw Normal View History

2019-11-27 09:39:44 +00:00
#pragma once
#include <Core/Types.h>
#include <Disks/IDisk.h>
#include <functional>
#include <unordered_map>
#include <boost/noncopyable.hpp>
#include <Poco/Util/AbstractConfiguration.h>
namespace DB
{
class Context;
/**
* Disk factory. Responsible for creating new disk objects.
*/
2019-11-27 09:39:44 +00:00
class DiskFactory final : private boost::noncopyable
{
public:
using Creator = std::function<DiskPtr(
const String & name,
const Poco::Util::AbstractConfiguration & config,
2019-11-27 09:39:44 +00:00
const String & config_prefix,
const Context & context)>;
static DiskFactory & instance();
void registerDiskType(const String & disk_type, Creator creator);
2019-11-27 09:39:44 +00:00
DiskPtr create(
const String & name,
const Poco::Util::AbstractConfiguration & config,
2019-11-27 09:39:44 +00:00
const String & config_prefix,
const Context & context) const;
private:
using DiskTypeRegistry = std::unordered_map<String, Creator>;
DiskTypeRegistry registry;
};
}