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 GENERAL_CONTROLLER_H 17 #define GENERAL_CONTROLLER_H 18 19 #include <memory> 20 #include <string_ex.h> 21 22 #include "datashare_business_error.h" 23 #include "datashare_errno.h" 24 #include "datashare_predicates.h" 25 #include "datashare_result_set.h" 26 #include "datashare_values_bucket.h" 27 #include "uri.h" 28 29 namespace OHOS { 30 namespace AAFwk { 31 class IDataAbilityObserver; 32 } 33 34 namespace DataShare { 35 class GeneralController { 36 public: 37 virtual ~GeneralController() = default; 38 39 virtual int Insert(const Uri &uri, const DataShareValuesBucket &value) = 0; 40 41 virtual int Update(const Uri &uri, const DataSharePredicates &predicates, const DataShareValuesBucket &value) = 0; 42 43 virtual int Delete(const Uri &uri, const DataSharePredicates &predicates) = 0; 44 45 virtual std::shared_ptr<DataShareResultSet> Query(const Uri &uri, const DataSharePredicates &predicates, 46 std::vector<std::string> &columns, DatashareBusinessError &businessError) = 0; 47 48 virtual int RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) = 0; 49 50 virtual int UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) = 0; 51 52 virtual void NotifyChange(const Uri &uri) = 0; 53 54 virtual std::pair<int32_t, int32_t> InsertEx(const Uri &uri, const DataShareValuesBucket &value) = 0; 55 56 virtual std::pair<int32_t, int32_t> UpdateEx( 57 const Uri &uri, const DataSharePredicates &predicates, const DataShareValuesBucket &value) = 0; 58 59 virtual std::pair<int32_t, int32_t> DeleteEx(const Uri &uri, const DataSharePredicates &predicates) = 0; 60 }; 61 } // namespace DataShare 62 } // namespace OHOS 63 #endif // GENERAL_CONTROLLER_H 64