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;
|
|
|
|
|
2019-11-28 19:11:49 +00:00
|
|
|
/**
|
|
|
|
* 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(
|
2019-11-28 19:11:49 +00:00
|
|
|
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();
|
|
|
|
|
2019-11-28 19:11:49 +00:00
|
|
|
void registerDiskType(const String & disk_type, Creator creator);
|
2019-11-27 09:39:44 +00:00
|
|
|
|
2019-11-28 19:11:49 +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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|