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 FRAMEWORKS_INNERKITSIMPL_MEDIA_LIBRARY_INCLUDE_MEDIA_LIB_DATASHAREHELPER_CONTAINER_H_
17 #define FRAMEWORKS_INNERKITSIMPL_MEDIA_LIBRARY_INCLUDE_MEDIA_LIB_DATASHAREHELPER_CONTAINER_H_
18 
19 #include "datashare_helper.h"
20 
21 namespace OHOS {
22 namespace Media {
23 #define EXPORT __attribute__ ((visibility ("default")))
24 /**
25  * @brief Utility class for file operations
26  *
27  * @since 1.0
28  * @version 1.0
29  */
30 class MediaLibraryHelperContainer {
31 public:
32     EXPORT MediaLibraryHelperContainer() = default;
33     EXPORT virtual ~MediaLibraryHelperContainer() = default;
34 
35     EXPORT static std::shared_ptr<MediaLibraryHelperContainer> GetInstance();
36     EXPORT void CreateDataShareHelper(const sptr<IRemoteObject> &token, const std::string &uri);
37     EXPORT void SetDataShareHelper(const std::shared_ptr<DataShare::DataShareHelper> &helper);
38     EXPORT std::shared_ptr<DataShare::DataShareHelper> GetDataShareHelper();
39 
40 private:
41     static std::mutex mutex_;
42     static std::shared_ptr<MediaLibraryHelperContainer> instance_;
43     static std::shared_ptr<DataShare::DataShareHelper> dataShareHelper_;
44 };
45 } // namespace Media
46 } // namespace  OHOS
47 
48 #endif // FRAMEWORKS_INNERKITSIMPL_MEDIA_LIBRARY_INCLUDE_MEDIA_LIB_DATASHAREHELPER_CONTAINER_H_
49