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 MULTI_VER_NATURAL_STORE_COMMIT_NOTIFY_DATA_H
17 #define MULTI_VER_NATURAL_STORE_COMMIT_NOTIFY_DATA_H
18 
19 #ifndef OMIT_MULTI_VER
20 #include <mutex>
21 
22 #include "kvdb_commit_notify_filterable_data.h"
23 #include "multi_ver_natural_store.h"
24 
25 namespace DistributedDB {
26 class MultiVerNaturalStoreCommitNotifyData final : public KvDBCommitNotifyFilterAbleData {
27 public:
28     MultiVerNaturalStoreCommitNotifyData(MultiVerNaturalStore *db, const CommitID &startCommitID,
29         const CommitID &endCommitID, Version curVersion);
30     ~MultiVerNaturalStoreCommitNotifyData();
31     DISABLE_COPY_ASSIGN_MOVE(MultiVerNaturalStoreCommitNotifyData);
32 
33     const std::list<Entry> GetInsertedEntries(int &errCode) const override;
34 
35     const std::list<Entry> GetUpdatedEntries(int &errCode) const override;
36 
37     const std::list<Entry> GetDeletedEntries(int &errCode) const override;
38 
39     bool IsCleared() const override;
40 
41     bool IsChangedDataEmpty() const override;
42 
43 private:
44     int FillInnerData() const;
45 
46     DECLARE_OBJECT_TAG(MultiVerNaturalStoreCommitNotifyData);
47 
48     mutable MultiVerNaturalStore *db_;
49     CommitID startCommitID_;
50     CommitID endCommitID_;
51     mutable MultiVerDiffData diffData_;
52     mutable bool isFilled_;
53     mutable std::mutex fillMutex_;
54     Version version_;
55 };
56 } // namespace DistributedDB
57 
58 #endif // MULTI_VER_NATURAL_STORE_COMMIT_NOTIFY_DATA_H
59 #endif