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 OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_DB_H 17 #define OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_DB_H 18 #include <functional> 19 #include <string> 20 21 #include "store/cursor.h" 22 #include "store/general_value.h" 23 #include "store/general_watcher.h" 24 #include "visibility.h" 25 namespace OHOS::DistributedData { 26 class API_EXPORT CloudDB { 27 public: 28 using Watcher = GeneralWatcher; 29 using Async = std::function<void(std::map<std::string, std::map<std::string, int32_t>>)>; 30 using Devices = std::vector<std::string>; 31 virtual ~CloudDB() = default; 32 33 virtual int32_t Execute(const std::string &table, const std::string &sql, const VBucket &extend); 34 35 virtual int32_t BatchInsert(const std::string &table, VBuckets &&values, VBuckets &extends); 36 37 virtual int32_t BatchUpdate(const std::string &table, VBuckets &&values, VBuckets &extends); 38 39 virtual int32_t BatchUpdate(const std::string &table, VBuckets &&values, const VBuckets &extends); 40 41 virtual int32_t BatchDelete(const std::string &table, const VBuckets &extends); 42 43 virtual std::shared_ptr<Cursor> Query(const std::string &table, const VBucket &extend); 44 45 virtual int32_t Sync(const Devices &devices, int32_t mode, const GenQuery &query, Async async, int32_t wait); 46 47 virtual int32_t Watch(int32_t origin, Watcher &watcher); 48 49 virtual int32_t Unwatch(int32_t origin, Watcher &watcher); 50 51 virtual int32_t Lock(); 52 53 virtual int32_t Heartbeat(); 54 55 virtual int32_t Unlock(); 56 57 virtual int64_t AliveTime(); 58 59 virtual int32_t Close(); 60 }; 61 } // namespace OHOS::DistributedData 62 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_FRAMEWORK_CLOUD_CLOUD_DB_H 63