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 KVDB_COMMIT_NOTIFY_FILTERABLE_DATA_H 17 #define KVDB_COMMIT_NOTIFY_FILTERABLE_DATA_H 18 19 #include "generic_kvdb.h" 20 #include "kvdb_conflict_entry.h" 21 #include "kvdb_commit_notify_data.h" 22 23 namespace DistributedDB { 24 class KvDBCommitNotifyFilterAbleData : public KvDBCommitNotifyData { 25 public: 26 KvDBCommitNotifyFilterAbleData(); 27 ~KvDBCommitNotifyFilterAbleData() override; 28 DISABLE_COPY_ASSIGN_MOVE(KvDBCommitNotifyFilterAbleData); 29 30 // get the new inserted entries. 31 const std::list<Entry> GetInsertedEntries(int &errCode) const override; 32 33 // get the new updated entries. 34 const std::list<Entry> GetUpdatedEntries(int &errCode) const override; 35 36 // get the new deleted entries. 37 const std::list<Entry> GetDeletedEntries(int &errCode) const override; 38 39 // get all conflict entries when commit. 40 const std::list<KvDBConflictEntry> GetCommitConflicts(int &errCode) const override; 41 42 // database is cleared by user in the commit. 43 bool IsCleared() const override; 44 45 // test if the data is empty or not after filtered. 46 bool IsChangedDataEmpty() const override; 47 48 // test if the conflict data is empty or not. 49 bool IsConflictedDataEmpty() const override; 50 51 // set the filter key. 52 virtual void SetFilterKey(const Key &key); 53 54 // set and ref the db that we belong to. 55 void SetMyDb(GenericKvDB *db, uint64_t notifyID); 56 57 // get ID of this notify. 58 uint64_t GetNotifyID() const; 59 60 private: 61 DECLARE_OBJECT_TAG(KvDBCommitNotifyFilterAbleData); 62 63 GenericKvDB *genericKvDB_; 64 uint64_t notifyID_; 65 }; 66 } // namespace DistributedDB 67 68 #endif // KVDB_COMMIT_NOTIFY_FILTERABLE_DATA_H 69