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 #include "dk_database.h"
16
17 #include <functional>
18 #include <iostream>
19 #include <thread>
20
21 #include "dk_context.h"
22
23 namespace DriveKit {
SaveRecords(std::shared_ptr<DKContext> context,std::vector<DKRecord> && records,DKSavePolicy policy,SaveRecordsCallback callback)24 DKLocalErrorCode DKDatabase::SaveRecords(std::shared_ptr<DKContext> context,
25 std::vector<DKRecord> &&records,
26 DKSavePolicy policy,
27 SaveRecordsCallback callback)
28 {
29 return DKLocalErrorCode::NO_ERROR;
30 }
SaveRecord(std::shared_ptr<DKContext> context,DKRecord && record,DKSavePolicy policy,SaveRecordCallback callback)31 DKLocalErrorCode DKDatabase::SaveRecord(std::shared_ptr<DKContext> context,
32 DKRecord &&record,
33 DKSavePolicy policy,
34 SaveRecordCallback callback)
35 {
36 return DKLocalErrorCode::NO_ERROR;
37 }
FetchRecords(std::shared_ptr<DKContext> context,DKRecordType recordType,DKFieldKeyArray & desiredKeys,int resultLimit,DKQueryCursor cursor,FetchRecordsCallback callback)38 DKLocalErrorCode DKDatabase::FetchRecords(std::shared_ptr<DKContext> context,
39 DKRecordType recordType,
40 DKFieldKeyArray &desiredKeys,
41 int resultLimit,
42 DKQueryCursor cursor,
43 FetchRecordsCallback callback)
44 {
45 return DKLocalErrorCode::NO_ERROR;
46 }
47
FetchRecordWithId(std::shared_ptr<DKContext> context,DKRecordType recordType,DKRecordId recordId,DKFieldKeyArray & desiredKeys,FetchRecordCallback callback)48 DKLocalErrorCode DKDatabase::FetchRecordWithId(std::shared_ptr<DKContext> context,
49 DKRecordType recordType,
50 DKRecordId recordId,
51 DKFieldKeyArray &desiredKeys,
52 FetchRecordCallback callback)
53 {
54 return DKLocalErrorCode::NO_ERROR;
55 }
56
DeleteRecords(std::shared_ptr<DKContext> context,std::vector<DKRecord> && records,DKSavePolicy policy,DeleteRecordsCallback callback)57 DKLocalErrorCode DKDatabase::DeleteRecords(std::shared_ptr<DKContext> context,
58 std::vector<DKRecord> &&records,
59 DKSavePolicy policy,
60 DeleteRecordsCallback callback)
61 {
62 return DKLocalErrorCode::NO_ERROR;
63 }
64
ModifyRecords(std::shared_ptr<DKContext> context,std::vector<DKRecord> && recordsToSave,std::vector<DKRecord> && recordsToDelete,DKSavePolicy policy,bool atomically,ModifyRecordsCallback callback)65 DKLocalErrorCode DKDatabase::ModifyRecords(std::shared_ptr<DKContext> context,
66 std::vector<DKRecord> &&recordsToSave,
67 std::vector<DKRecord> &&recordsToDelete,
68 DKSavePolicy policy,
69 bool atomically,
70 ModifyRecordsCallback callback)
71 {
72 return DKLocalErrorCode::NO_ERROR;
73 }
74
FetchRecordsWithQuery(std::shared_ptr<DKContext> context,DKFieldKeyArray & desiredKeys,DKQuery query,int resultLimit,DKQueryCursor cursor,FetchRecordsCallback callback)75 DKLocalErrorCode DKDatabase::FetchRecordsWithQuery(std::shared_ptr<DKContext> context,
76 DKFieldKeyArray &desiredKeys,
77 DKQuery query,
78 int resultLimit,
79 DKQueryCursor cursor,
80 FetchRecordsCallback callback)
81 {
82 return DKLocalErrorCode::NO_ERROR;
83 }
84
FetchDatabaseChanges(std::shared_ptr<DKContext> context,DKRecordType recordType,DKFieldKeyArray & desiredKeys,int resultLimit,DKQueryCursor cursor,FetchDatabaseCallback callback)85 DKLocalErrorCode DKDatabase::FetchDatabaseChanges(std::shared_ptr<DKContext> context,
86 DKRecordType recordType,
87 DKFieldKeyArray &desiredKeys,
88 int resultLimit,
89 DKQueryCursor cursor,
90 FetchDatabaseCallback callback)
91 {
92 return DKLocalErrorCode::NO_ERROR;
93 }
94
GetStartCursor(DKRecordType recordType,DKQueryCursor & cursor)95 DKError DKDatabase::GetStartCursor(DKRecordType recordType, DKQueryCursor &cursor)
96 {
97 DKError e;
98 return e;
99 }
GenerateIds(int count,std::vector<DKRecordId> & ids)100 DKError DKDatabase::GenerateIds(int count, std::vector<DKRecordId> &ids)
101 {
102 DKError e;
103 return e;
104 }
GetLock(DKLock & lock)105 DKError DKDatabase::GetLock(DKLock &lock)
106 {
107 DKError e;
108 return e;
109 }
DeleteLock(DKLock lock)110 void DKDatabase::DeleteLock(DKLock lock) {}
GetAssetsDownloader()111 std::shared_ptr<DKAssetsDownloader> DKDatabase::GetAssetsDownloader()
112 {
113 return std::make_shared<DKAssetsDownloader>(shared_from_this());
114 }
NewAssetReadSession(DKRecordType recordType,DKRecordId recordId,DKFieldKey assetKey,DKAssetPath assetPath)115 std::shared_ptr<DKAssetReadSession> DKDatabase::NewAssetReadSession(DKRecordType recordType,
116 DKRecordId recordId,
117 DKFieldKey assetKey,
118 DKAssetPath assetPath)
119 {
120 return std::make_shared<DKAssetReadSession>();
121 }
DKDatabase(std::shared_ptr<DKContainer> container,DKDatabaseScope scope)122 DKDatabase::DKDatabase(std::shared_ptr<DKContainer> container, DKDatabaseScope scope)
123 {
124 }
Init()125 void DKDatabase::Init()
126 {
127 }
128 } // namespace DriveKit
129