1bc03f14fSopenharmony_ci/*
2bc03f14fSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3bc03f14fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4bc03f14fSopenharmony_ci * you may not use this file except in compliance with the License.
5bc03f14fSopenharmony_ci * You may obtain a copy of the License at
6bc03f14fSopenharmony_ci *
7bc03f14fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8bc03f14fSopenharmony_ci *
9bc03f14fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10bc03f14fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11bc03f14fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bc03f14fSopenharmony_ci * See the License for the specific language governing permissions and
13bc03f14fSopenharmony_ci * limitations under the License.
14bc03f14fSopenharmony_ci */
15bc03f14fSopenharmony_ci
16bc03f14fSopenharmony_ci#ifndef OHOS_DISTRIBUTED_DATA_PASTEBOARD_ADAPTER_DATA_SHARE_DELEGATE_H
17bc03f14fSopenharmony_ci#define OHOS_DISTRIBUTED_DATA_PASTEBOARD_ADAPTER_DATA_SHARE_DELEGATE_H
18bc03f14fSopenharmony_ci
19bc03f14fSopenharmony_ci#include <cstdint>
20bc03f14fSopenharmony_ci#include <memory>
21bc03f14fSopenharmony_ci#include <shared_mutex>
22bc03f14fSopenharmony_ci
23bc03f14fSopenharmony_ci#include "datashare_helper.h"
24bc03f14fSopenharmony_ci
25bc03f14fSopenharmony_cinamespace OHOS::MiscServices {
26bc03f14fSopenharmony_ciusing ChangeInfo = DataShare::DataShareObserver::ChangeInfo;
27bc03f14fSopenharmony_ciclass DataShareDelegate {
28bc03f14fSopenharmony_cipublic:
29bc03f14fSopenharmony_ci    static DataShareDelegate &GetInstance();
30bc03f14fSopenharmony_ci    int32_t RegisterObserver(const std::string &key, sptr<AAFwk::IDataAbilityObserver> observer);
31bc03f14fSopenharmony_ci    int32_t UnregisterObserver(const std::string &key, sptr<AAFwk::IDataAbilityObserver> observer);
32bc03f14fSopenharmony_ci    int32_t GetValue(const std::string &key, std::string &value);
33bc03f14fSopenharmony_ci
34bc03f14fSopenharmony_ciprivate:
35bc03f14fSopenharmony_ci    DataShareDelegate() = default;
36bc03f14fSopenharmony_ci    ~DataShareDelegate() = default;
37bc03f14fSopenharmony_ci    DISALLOW_COPY_AND_MOVE(DataShareDelegate);
38bc03f14fSopenharmony_ci
39bc03f14fSopenharmony_ci    static void Initialize();
40bc03f14fSopenharmony_ci    bool ReleaseDataShareHelper(std::shared_ptr<DataShare::DataShareHelper> helper);
41bc03f14fSopenharmony_ci    std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper();
42bc03f14fSopenharmony_ci    Uri MakeUri(const std::string &key);
43bc03f14fSopenharmony_ci
44bc03f14fSopenharmony_ci    static std::mutex mutex_;
45bc03f14fSopenharmony_ci    static DataShareDelegate *instance_;
46bc03f14fSopenharmony_ci    static sptr<IRemoteObject> remoteObj_;
47bc03f14fSopenharmony_ci};
48bc03f14fSopenharmony_ci} // namespace OHOS::MiscServices
49bc03f14fSopenharmony_ci
50bc03f14fSopenharmony_ci#endif // OHOS_DISTRIBUTED_DATA_PASTEBOARD_ADAPTER_DATA_SHARE_DELEGATE_H