1 /* 2 * Copyright (c) 2023 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 RELATIONAL_STORE_CLIENT_H 17 #define RELATIONAL_STORE_CLIENT_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <string> 22 #include <set> 23 24 #include "store_observer.h" 25 #include "store_types.h" 26 27 typedef struct sqlite3 sqlite3; 28 29 struct ClientChangedData { 30 std::map<std::string, DistributedDB::ChangeProperties> tableData; 31 }; 32 33 using ClientObserver = std::function<void(ClientChangedData &clientChangedData)>; 34 using StoreObserver = DistributedDB::StoreObserver; 35 36 DB_API DistributedDB::DBStatus RegisterClientObserver(sqlite3 *db, const ClientObserver &clientObserver); 37 38 DB_API DistributedDB::DBStatus UnRegisterClientObserver(sqlite3 *db); 39 40 DB_API DistributedDB::DBStatus RegisterStoreObserver(sqlite3 *db, const std::shared_ptr<StoreObserver> &storeObserver); 41 42 DB_API DistributedDB::DBStatus UnregisterStoreObserver(sqlite3 *db, 43 const std::shared_ptr<StoreObserver> &storeObserver); 44 45 DB_API DistributedDB::DBStatus UnregisterStoreObserver(sqlite3 *db); 46 47 DB_API DistributedDB::DBStatus DropLogicDeletedData(sqlite3 *db, const std::string &tableName, uint64_t cursor); 48 49 DB_API DistributedDB::DBStatus Lock(const std::string &tableName, const std::vector<std::vector<uint8_t>> &hashKey, 50 sqlite3 *db); 51 52 DB_API DistributedDB::DBStatus UnLock(const std::string &tableName, const std::vector<std::vector<uint8_t>> &hashKey, 53 sqlite3 *db); 54 #endif // RELATIONAL_STORE_CLIENT_H 55