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_DATA_H
17 #define KVDB_COMMIT_NOTIFY_DATA_H
18 
19 #include <list>
20 
21 #include "db_types.h"
22 #include "ref_object.h"
23 #include "macro_utils.h"
24 #include "kvdb_conflict_entry.h"
25 
26 namespace DistributedDB {
27 // Data from local commit or syncer commit.
28 class KvDBCommitNotifyData : public RefObject {
29 public:
30     KvDBCommitNotifyData() = default;
~KvDBCommitNotifyData()31     virtual ~KvDBCommitNotifyData() {}
32     DISABLE_COPY_ASSIGN_MOVE(KvDBCommitNotifyData);
33 
34     // get the new inserted entries.
35     virtual const std::list<Entry> GetInsertedEntries(int &errCode) const = 0;
36 
37     // get the new updated entries.
38     virtual const std::list<Entry> GetUpdatedEntries(int &errCode) const = 0;
39 
40     // get the new deleted entries.
41     virtual const std::list<Entry> GetDeletedEntries(int &errCode) const = 0;
42 
43     // get all conflict entries when commit.
44     virtual const std::list<KvDBConflictEntry> GetCommitConflicts(int &errCode) const = 0;
45 
46     // database is cleared by user in the commit.
47     virtual bool IsCleared() const = 0;
48 
49     // test if the inserted/updated/deleted data is empty or not.
50     virtual bool IsChangedDataEmpty() const = 0;
51 
52     // test if the conflict data is empty or not.
53     virtual bool IsConflictedDataEmpty() const = 0;
54 };
55 } // namespace DistributedDB
56 
57 #endif // KVDB_COMMIT_NOTIFY_DATA_H
58