1 /*
2  * Copyright (C) 2022 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_MEDIALIBRARY_UNISTORE_H
17 #define OHOS_MEDIALIBRARY_UNISTORE_H
18 
19 #include "ability_context.h"
20 #include "medialibrary_command.h"
21 #include "rdb_errno.h"
22 #include "rdb_helper.h"
23 #include "rdb_open_callback.h"
24 #include "rdb_store.h"
25 #include "rdb_store_config.h"
26 #include "rdb_types.h"
27 
28 namespace OHOS {
29 namespace Media {
30 #define EXPORT __attribute__ ((visibility ("default")))
31 class MediaLibraryUnistore {
32 public:
33     EXPORT MediaLibraryUnistore() = default;
34     EXPORT virtual ~MediaLibraryUnistore() = default;
35 
36     EXPORT virtual int32_t Init() = 0;
37     EXPORT virtual void Stop() = 0;
38 
39     EXPORT virtual int32_t Insert(MediaLibraryCommand &cmd, int64_t &rowId) = 0;
40     EXPORT virtual int32_t Delete(MediaLibraryCommand &cmd, int32_t &rowId) = 0;
41     EXPORT virtual int32_t Update(MediaLibraryCommand &cmd, int32_t &rowId) = 0;
42     EXPORT virtual int32_t BatchInsert(MediaLibraryCommand &cmd, int64_t& outInsertNum,
43         const std::vector<NativeRdb::ValuesBucket>& values) = 0;
Query(MediaLibraryCommand & cmd,const std::vector<std::string> & columns)44     EXPORT virtual std::shared_ptr<NativeRdb::ResultSet> Query(MediaLibraryCommand &cmd,
45         const std::vector<std::string> &columns)
46     {
47         return nullptr;
48     }
49 
SyncPullTable(const std::string & bundleName,const std::string & tableName,int32_t rowId,std::vector<std::string> & devices)50     EXPORT virtual bool SyncPullTable(const std::string &bundleName, const std::string &tableName,
51         int32_t rowId, std::vector<std::string> &devices)
52     {
53         return false;
54     }
55 
56     EXPORT virtual bool SyncPushTable(const std::string &bundleName, const std::string &tableName,
57         int32_t rowId, std::vector<std::string> &devices, bool isBlock = false)
58     {
59         return false;
60     }
61 
ExecuteSql(const std::string & sql)62     EXPORT virtual int32_t ExecuteSql(const std::string &sql)
63     {
64         return NativeRdb::E_NOT_SUPPORT;
65     }
66 
67     EXPORT virtual std::shared_ptr<NativeRdb::ResultSet> QuerySql(const std::string &sql,
68         const std::vector<std::string> &selectionArgs = std::vector<std::string>())
69     {
70         return nullptr;
71     }
72 };
73 } // namespace Media
74 } // namespace OHOS
75 
76 #endif // OHOS_MEDIALIBRARY_UNISTORE_H
77