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 #ifndef DEFAULT_FACTORY_H 17 #define DEFAULT_FACTORY_H 18 19 #include "ikvdb.h" 20 #include "ikvdb_factory.h" 21 22 namespace DistributedDB { 23 class DefaultFactory final : public IKvDBFactory { 24 public: DefaultFactory()25 DefaultFactory() noexcept {} ~DefaultFactory()26 ~DefaultFactory() override {} 27 28 DISABLE_COPY_ASSIGN_MOVE(DefaultFactory); 29 IKvDB *CreateKvDb(KvDBType kvDbType, int &errCode) override; 30 31 #ifndef OMIT_MULTI_VER 32 // Create a key-value database for commit storage module. 33 IKvDB *CreateCommitStorageDB(int &errCode) override; 34 35 // Create the multi version storage for multi version natural store 36 IKvDBMultiVerDataStorage *CreateMultiVerStorage(int &errCode) override; 37 38 // Create the commit storage. The object can be deleted directly when it is not needed. 39 IKvDBCommitStorage *CreateMultiVerCommitStorage(int &errCode) override; 40 #endif 41 private: 42 // Create a local kv db 43 IKvDB *CreateLocalKvDB(int &errCode); 44 45 #ifndef OMIT_MULTI_VER 46 // Create the a natural store, it contains a commit version and commit storage kvdb. 47 IKvDB *CreateMultiVerNaturalStore(int &errCode); 48 #endif 49 50 IKvDB *CreateSingleVerNaturalStore(int &errCode); 51 52 IKvDB *CreateRdSingleVerNaturalStore(int &errCode); 53 }; 54 } // namespace DistributedDB 55 #endif // DEFAULT_FACTORY_H 56