1 | /** |
2 | * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | * |
16 | * \author guonix |
17 | * \date Oct 2020 |
18 | * \brief |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include <ailego/pattern/factory.h> |
24 | #include <ailego/pattern/singleton.h> |
25 | #include "meta_store.h" |
26 | |
27 | namespace proxima { |
28 | namespace be { |
29 | namespace meta { |
30 | |
31 | /*! |
32 | * MetaStoreFactory in charging create meta store object |
33 | */ |
34 | class MetaStoreFactory : public ailego::Singleton<MetaStoreFactory> { |
35 | public: |
36 | //! Alias for Cache & CacheIter |
37 | using Cache = std::map<std::string, MetaStorePtr>; |
38 | using CacheIter = Cache::iterator; |
39 | |
40 | public: |
41 | //! Return singleton MateStore instance |
42 | MetaStorePtr create(const char *name, const ailego::Uri *uri); |
43 | |
44 | private: |
45 | //! Meta store cache |
46 | Cache store_cache_{}; |
47 | }; |
48 | |
49 | |
50 | //! Register MetaStore |
51 | #define META_FACTORY_REGISTER_INSTANCE_ALIAS(__NAME__, __IMPL__, ...) \ |
52 | AILEGO_FACTORY_REGISTER(__NAME__, MetaStore, __IMPL__, ##__VA_ARGS__) |
53 | |
54 | |
55 | } // namespace meta |
56 | } // namespace be |
57 | } // namespace proxima |
58 | |