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 RINGTONE_RDBSTORE_H 17 #define RINGTONE_RDBSTORE_H 18 19 #include "ringtone_unistore.h" 20 #include "ringtone_rdb_callbacks.h" 21 22 namespace OHOS { 23 namespace Media { 24 #define EXPORT __attribute__ ((visibility ("default"))) 25 26 class RingtoneRdbStore final : public RingtoneUnistore { 27 public: 28 EXPORT static std::shared_ptr<RingtoneUnistore> GetInstance( 29 const std::shared_ptr<OHOS::AbilityRuntime::Context> &context = nullptr); 30 EXPORT virtual ~RingtoneRdbStore(); 31 32 explicit RingtoneRdbStore(const std::shared_ptr<OHOS::AbilityRuntime::Context> &context); 33 34 EXPORT virtual int32_t Init() override; 35 EXPORT virtual void Stop() override; 36 37 EXPORT virtual int32_t Insert(RingtoneDataCommand &cmd, int64_t &rowId) override; 38 EXPORT virtual int32_t Delete(RingtoneDataCommand &cmd, int32_t &deletedRows) override; 39 EXPORT virtual int32_t Update(RingtoneDataCommand &cmd, int32_t &changedRows) override; 40 EXPORT std::shared_ptr<NativeRdb::ResultSet> Query(RingtoneDataCommand &cmd, 41 const std::vector<std::string> &columns) override; 42 43 EXPORT int32_t ExecuteSql(const std::string &sql) override; 44 EXPORT std::shared_ptr<NativeRdb::ResultSet> QuerySql(const std::string &sql, 45 const std::vector<std::string> &selectionArgs = std::vector<std::string>()) override; 46 EXPORT std::shared_ptr<NativeRdb::RdbStore> GetRaw() override; 47 private: 48 std::string bundleName_ {RINGTONE_BUNDLE_NAME}; 49 NativeRdb::RdbStoreConfig config_ {""}; 50 static std::shared_ptr<NativeRdb::RdbStore> rdbStore_; 51 }; 52 } // namespace Media 53 } // namespace OHOS 54 55 #endif // RINGTONE_RDBSTORE_H 56