1 | #pragma once |
2 | |
3 | #include <Poco/AutoPtr.h> |
4 | #include <Poco/Util/AbstractConfiguration.h> |
5 | #include <Poco/Timestamp.h> |
6 | |
7 | #include <atomic> |
8 | #include <memory> |
9 | #include <string> |
10 | #include <set> |
11 | |
12 | namespace DB |
13 | { |
14 | using LoadablesConfigurationPtr = Poco::AutoPtr<Poco::Util::AbstractConfiguration>; |
15 | |
16 | /// Base interface for configurations source for Loadble objects, which can be |
17 | /// loaded with ExternalLoader. Configurations may came from filesystem (XML-files), |
18 | /// server memory (from database), etc. It's important that main result of this class |
19 | /// (LoadablesConfigurationPtr) may contain more than one loadable config, |
20 | /// each one with own key, which can be obtained with keys method, |
21 | /// for example multiple dictionaries can be defined in single .xml file. |
22 | class IExternalLoaderConfigRepository |
23 | { |
24 | public: |
25 | /// Returns the name of the repository. |
26 | virtual const std::string & getName() const = 0; |
27 | |
28 | /// Whether this repository is temporary: |
29 | /// it's created and destroyed while executing the same query. |
30 | virtual bool isTemporary() const { return false; } |
31 | |
32 | /// Return all available sources of loadables structure |
33 | /// (all .xml files from fs, all entities from database, etc) |
34 | virtual std::set<std::string> getAllLoadablesDefinitionNames() = 0; |
35 | |
36 | /// Checks that source of loadables configuration exist. |
37 | virtual bool exists(const std::string & path) = 0; |
38 | |
39 | /// Returns entity last update time |
40 | virtual Poco::Timestamp getUpdateTime(const std::string & path) = 0; |
41 | |
42 | /// Load configuration from some concrete source to AbstractConfiguration |
43 | virtual LoadablesConfigurationPtr load(const std::string & path) = 0; |
44 | |
45 | virtual ~IExternalLoaderConfigRepository() {} |
46 | }; |
47 | |
48 | } |
49 | |