1 /* 2 * Copyright (c) 2022 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 #ifndef OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_STORE_RESULT_SET_H 16 #define OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_STORE_RESULT_SET_H 17 #include <memory> 18 #include <shared_mutex> 19 #include "convertor.h" 20 #include "kv_store_nb_delegate.h" 21 #include "kv_store_result_set.h" 22 #include "kvstore_result_set.h" 23 namespace OHOS::DistributedKv { 24 class StoreResultSet : public KvStoreResultSet { 25 public: 26 using DBResultSet = DistributedDB::KvStoreResultSet; 27 using DBStore = DistributedDB::KvStoreNbDelegate; 28 using DBEntry = DistributedDB::Entry; 29 StoreResultSet(DBResultSet *impl, std::shared_ptr<DBStore> dbStore, const Convertor &convert); 30 ~StoreResultSet(); 31 int GetCount() const override; 32 int GetPosition() const override; 33 bool MoveToFirst() override; 34 bool MoveToLast() override; 35 bool MoveToNext() override; 36 bool MoveToPrevious() override; 37 bool Move(int offset) override; 38 bool MoveToPosition(int position) override; 39 bool IsFirst() const override; 40 bool IsLast() const override; 41 bool IsBeforeFirst() const override; 42 bool IsAfterLast() const override; 43 Status GetEntry(Entry &entry) const override; 44 Status Close() override; 45 46 private: 47 mutable std::shared_mutex mutex_; 48 DBResultSet *impl_; 49 std::shared_ptr<DBStore> dbStore_; 50 const Convertor &convert_; 51 }; 52 } // namespace OHOS::DistributedKv 53 #endif // OHOS_DISTRIBUTED_DATA_FRAMEWORKS_KVDB_STORE_RESULT_SET_H 54