blob: 998ef569ed5a188ac9d7b9d8a04064dc866eb09d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#pragma once
#include <Disks/IDisk.h>
#include <Interpreters/Context_fwd.h>
#include <base/types.h>
#include <boost/noncopyable.hpp>
#include <Poco/Util/AbstractConfiguration.h>
#include <functional>
#include <map>
#include <unordered_map>
namespace DB
{
using DisksMap = std::map<String, DiskPtr>;
/**
* Disk factory. Responsible for creating new disk objects.
*/
class DiskFactory final : private boost::noncopyable
{
public:
using Creator = std::function<DiskPtr(
const String & name,
const Poco::Util::AbstractConfiguration & config,
const String & config_prefix,
ContextPtr context,
const DisksMap & map)>;
static DiskFactory & instance();
void registerDiskType(const String & disk_type, Creator creator);
DiskPtr create(
const String & name,
const Poco::Util::AbstractConfiguration & config,
const String & config_prefix,
ContextPtr context,
const DisksMap & map) const;
private:
using DiskTypeRegistry = std::unordered_map<String, Creator>;
DiskTypeRegistry registry;
};
}
|