1 /* 2 * Copyright (c) 2024 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 COLLABORATION_EDIT_DB_STORE_H 17 #define COLLABORATION_EDIT_DB_STORE_H 18 19 #include "cloud_db_proxy.h" 20 #include "db_store_config.h" 21 #include "grd_type_export.h" 22 23 namespace OHOS::CollaborationEdit { 24 class DBStore { 25 public: 26 DBStore(GRD_DB *db, std::string name); 27 ~DBStore(); 28 std::string GetLocalId(); 29 GRD_DB *GetDB(); 30 int32_t Sync(GRD_SyncModeE mode, uint64_t syncId, GRD_SyncTaskCallbackFuncT callbackFunc); 31 int32_t SetThreadPool(); 32 33 int ApplyUpdate(std::string &applyInfo); 34 int WriteUpdate(const char *equipId, const uint8_t *data, uint32_t size, const std::string &watermark); 35 int GetRelativePos(const char *tableName, const char *nodeSize, uint32_t pos, std::string &relPos); 36 int GetAbsolutePos(const char *tableName, const char *relPos, const char *nodeSize, uint32_t *pos); 37 void SetCloudDbProxy(CloudDbProxy* proxy, GRD_ICloudDBT *cloudDB); 38 GRD_ICloudDBT *GetCloudDB(); 39 void FreeCloudDB(); 40 private: 41 GRD_DB *db_ = nullptr; 42 std::string name_; 43 std::shared_ptr<std::string> localId_; 44 CloudDbProxy* proxy_ = nullptr; 45 GRD_ICloudDBT *cloudDB_ = nullptr; 46 }; 47 } // namespace OHOS::CollaborationEdit 48 #endif // COLLABORATION_EDIT_DB_STORE_H 49