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_EXTENSION_CLOUD_DB_IMPL_H
17 #define OHOS_DISTRIBUTED_DATA_SERVICES_EXTENSION_CLOUD_DB_IMPL_H
18 
19 #include "cloud/cloud_db.h"
20 #include "cloud/schema_meta.h"
21 #include "cloud_extension.h"
22 #include "store/cursor.h"
23 #include "store/general_value.h"
24 
25 namespace OHOS::CloudData {
26 using DBVBucket = DistributedData::VBucket;
27 using DBVBuckets = DistributedData::VBuckets;
28 using DBCursor = DistributedData::Cursor;
29 using DBMeta = DistributedData::Database;
30 class CloudDbImpl : public DistributedData::CloudDB {
31 public:
32     explicit CloudDbImpl(OhCloudExtCloudDatabase *database);
33     ~CloudDbImpl();
34     int32_t Execute(const std::string &table, const std::string &sql, const DBVBucket &extend) override;
35     int32_t BatchInsert(const std::string &table, DBVBuckets &&values, DBVBuckets &extends) override;
36     int32_t BatchUpdate(const std::string &table, DBVBuckets &&values, DBVBuckets &extends) override;
37     int32_t BatchUpdate(const std::string &table, DBVBuckets &&values, const DBVBuckets &extends) override;
38     int32_t BatchDelete(const std::string &table, DBVBuckets &extends) override;
39     std::shared_ptr<DBCursor> Query(const std::string &table, const DBVBucket &extend) override;
40     int32_t Lock() override;
41     int32_t Heartbeat() override;
42     int32_t Unlock() override;
43     int64_t AliveTime() override;
44     int32_t Close() override;
45 
46 private:
47 
48     OhCloudExtCloudDatabase *database_ = nullptr;
49     int32_t interval_ = 0;
50 };
51 } // namespace OHOS::CloudData
52 #endif // OHOS_DISTRIBUTED_DATA_SERVICES_EXTENSION_CLOUD_DB_IMPL_H
53