• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_predicates.h"
24 #include "datashare_result_set.h"
25 #include "datashare_values_bucket.h"
26 #include "uri.h"
27 
28 namespace OHOS {
29 namespace AAFwk {
30 class IDataAbilityObserver;
31 }
32 
33 namespace DataShare {
34 class GeneralController {
35 public:
36     virtual ~GeneralController() = default;
37 
38     virtual int Insert(const Uri &uri, const DataShareValuesBucket &value) = 0;
39 
40     virtual int Update(const Uri &uri, const DataSharePredicates &predicates, const DataShareValuesBucket &value) = 0;
41 
42     virtual int Delete(const Uri &uri, const DataSharePredicates &predicates) = 0;
43 
44     virtual std::shared_ptr<DataShareResultSet> Query(const Uri &uri, const DataSharePredicates &predicates,
45         std::vector<std::string> &columns, DatashareBusinessError &businessError) = 0;
46 
47     virtual void RegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) = 0;
48 
49     virtual void UnregisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver) = 0;
50 
51     virtual void NotifyChange(const Uri &uri) = 0;
52 };
53 } // namespace DataShare
54 } // namespace OHOS
55 #endif // GENERAL_CONTROLLER_H
56