10fbfc30aSopenharmony_ci/*
20fbfc30aSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
30fbfc30aSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40fbfc30aSopenharmony_ci * you may not use this file except in compliance with the License.
50fbfc30aSopenharmony_ci * You may obtain a copy of the License at
60fbfc30aSopenharmony_ci *
70fbfc30aSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80fbfc30aSopenharmony_ci *
90fbfc30aSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100fbfc30aSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110fbfc30aSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120fbfc30aSopenharmony_ci * See the License for the specific language governing permissions and
130fbfc30aSopenharmony_ci * limitations under the License.
140fbfc30aSopenharmony_ci */
150fbfc30aSopenharmony_ci
160fbfc30aSopenharmony_ci#ifndef CALENDAR_DATA_SHARE_HELPER_MANAGER_H
170fbfc30aSopenharmony_ci#define CALENDAR_DATA_SHARE_HELPER_MANAGER_H
180fbfc30aSopenharmony_ci
190fbfc30aSopenharmony_ci#include <memory>
200fbfc30aSopenharmony_ci#include "singleton.h"
210fbfc30aSopenharmony_ci#include "datashare_helper.h"
220fbfc30aSopenharmony_ci
230fbfc30aSopenharmony_cinamespace OHOS::CalendarApi {
240fbfc30aSopenharmony_ciclass DataShareHelperManager : public OHOS::Singleton<DataShareHelperManager> {
250fbfc30aSopenharmony_cipublic:
260fbfc30aSopenharmony_ci    void SetDataShareHelper(std::shared_ptr<DataShare::DataShareHelper> helper);
270fbfc30aSopenharmony_ci    std::shared_ptr<DataShare::DataShareHelper> GetDataShareHelper();
280fbfc30aSopenharmony_ci    /**
290fbfc30aSopenharmony_ci     * @brief Inserts a single data record into the database.
300fbfc30aSopenharmony_ci     *
310fbfc30aSopenharmony_ci     * @param uri Indicates the path of the data to operate.
320fbfc30aSopenharmony_ci     * @param value  Indicates the data record to insert. If this parameter is null, a blank row will be inserted.
330fbfc30aSopenharmony_ci     *
340fbfc30aSopenharmony_ci     * @return Returns the index of the inserted data record.
350fbfc30aSopenharmony_ci     */
360fbfc30aSopenharmony_ci    int Insert(const Uri &uri, const DataShare::DataShareValuesBucket &value);
370fbfc30aSopenharmony_ci
380fbfc30aSopenharmony_ci     /**
390fbfc30aSopenharmony_ci     * @brief batch insert data records into the database.
400fbfc30aSopenharmony_ci     *
410fbfc30aSopenharmony_ci     * @param uri Indicates the path of the data to operate.
420fbfc30aSopenharmony_ci     * @param values  Indicates the data records to insert. If this parameter is null, a blank row will be inserted.
430fbfc30aSopenharmony_ci     *
440fbfc30aSopenharmony_ci     * @return Returns the index of the inserted data count.
450fbfc30aSopenharmony_ci     */
460fbfc30aSopenharmony_ci    int BatchInsert(const Uri &uri, const std::vector<DataShare::DataShareValuesBucket> &values);
470fbfc30aSopenharmony_ci
480fbfc30aSopenharmony_ci    /**
490fbfc30aSopenharmony_ci     * @brief Updates data records in the database.
500fbfc30aSopenharmony_ci     *
510fbfc30aSopenharmony_ci     * @param uri Indicates the path of data to update.
520fbfc30aSopenharmony_ci     * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null.
530fbfc30aSopenharmony_ci     * @param value Indicates the data to update. This parameter can be null.
540fbfc30aSopenharmony_ci     *
550fbfc30aSopenharmony_ci     * @return Returns the number of data records updated.
560fbfc30aSopenharmony_ci     */
570fbfc30aSopenharmony_ci    int Update(const Uri &uri, const DataShare::DataSharePredicates &predicates,
580fbfc30aSopenharmony_ci        const DataShare::DataShareValuesBucket &value);
590fbfc30aSopenharmony_ci
600fbfc30aSopenharmony_ci    /**
610fbfc30aSopenharmony_ci     * @brief Deletes one or more data records from the database.
620fbfc30aSopenharmony_ci     *
630fbfc30aSopenharmony_ci     * @param uri Indicates the path of the data to operate.
640fbfc30aSopenharmony_ci     * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null.
650fbfc30aSopenharmony_ci     *
660fbfc30aSopenharmony_ci     * @return Returns the number of data records deleted.
670fbfc30aSopenharmony_ci     */
680fbfc30aSopenharmony_ci    int Delete(const Uri &uri, const DataShare::DataSharePredicates &predicates);
690fbfc30aSopenharmony_ci
700fbfc30aSopenharmony_ci    /**
710fbfc30aSopenharmony_ci     * @brief Query records from the database.
720fbfc30aSopenharmony_ci     *
730fbfc30aSopenharmony_ci     * @param uri Indicates the path of data to query.
740fbfc30aSopenharmony_ci     * @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null.
750fbfc30aSopenharmony_ci     * @param columns Indicates the columns to query. If this parameter is null, all columns are queried.
760fbfc30aSopenharmony_ci     * @param businessError Indicates the error by query.
770fbfc30aSopenharmony_ci     *
780fbfc30aSopenharmony_ci     * @return Returns the query result.
790fbfc30aSopenharmony_ci     */
800fbfc30aSopenharmony_ci    std::shared_ptr<DataShare::DataShareResultSet> Query(const Uri &uri,
810fbfc30aSopenharmony_ci        const DataShare::DataSharePredicates &predicates, std::vector<std::string> &columns,
820fbfc30aSopenharmony_ci        DataShare::DatashareBusinessError *businessError = nullptr);
830fbfc30aSopenharmony_ciprivate:
840fbfc30aSopenharmony_ci    std::shared_ptr<DataShare::DataShareHelper> dataShareHelper;
850fbfc30aSopenharmony_ci};
860fbfc30aSopenharmony_ci} // namespace OHOS::CalendarApi
870fbfc30aSopenharmony_ci
880fbfc30aSopenharmony_ci#endif // CALENDAR_DATA_SHARE_HELPER_MANAGER_H