1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "syncer_factory.h"
17 
18 #include "ikvdb_sync_interface.h"
19 #include "multi_ver_syncer.h"
20 #include "single_ver_kv_syncer.h"
21 #ifdef RELATIONAL_STORE
22 #include "single_ver_relational_syncer.h"
23 #endif
24 
25 namespace DistributedDB {
GetSyncer(int type)26 std::shared_ptr<ISyncer> SyncerFactory::GetSyncer(int type)
27 {
28     if (type == ISyncInterface::SYNC_SVD) {
29         std::shared_ptr<ISyncer> singleVerSyncer(std::make_shared<SingleVerKVSyncer>());
30         return singleVerSyncer;
31 #ifndef OMIT_MULTI_VER
32     } else if (type == ISyncInterface::SYNC_MVD) {
33         std::shared_ptr<ISyncer> multiVerSyncer(std::make_shared<MultiVerSyncer>());
34         return multiVerSyncer;
35 #endif
36 #ifdef RELATIONAL_STORE
37     } else if (type == ISyncInterface::SYNC_RELATION) {
38         std::shared_ptr<ISyncer> relationalSyncer(std::make_shared<SingleVerRelationalSyncer>());
39         return relationalSyncer;
40 #endif
41     } else {
42         return nullptr;
43     }
44 }
45 } // namespace DistributedDB
46