1 /*
2  * Copyright (c) 2020-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 OHOS_BUNDLE_MAP_H
17 #define OHOS_BUNDLE_MAP_H
18 
19 #include "bundle_info.h"
20 #include "nocopyable.h"
21 #include "stdint.h"
22 #include "utils_list.h"
23 
24 namespace OHOS {
25 class BundleMap {
26 public:
GetInstance()27     static BundleMap *GetInstance()
28     {
29         static BundleMap instance;
30         return &instance;
31     }
32     ~BundleMap();
33 
34     void Add(BundleInfo *bundleInfo);
35     bool Update(BundleInfo *bundleInfo);
36     BundleInfo *Get(const char *bundleName) const;
37     uint8_t GetBundleInfos(int32_t flags, BundleInfo **bundleInfos, int32_t *len) const;
38     uint8_t GetBundleInfosInner(List<BundleInfo *> &bundleInfos) const;
39     uint8_t GetBundleInfosNoReplication(int32_t flags, BundleInfo **bundleInfos, int32_t *len) const;
40     uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo &bundleInfo) const;
41     void Erase(const char *bundleName);
42     void EraseAll();
43 
44 private:
45     BundleMap();
46     void GetCopyBundleInfo(uint32_t flags, const BundleInfo *bundleInfo, BundleInfo &newBundleInfo) const;
47     List<BundleInfo *> *bundleInfos_;
48 
49     DISALLOW_COPY_AND_MOVE(BundleMap);
50 };
51 } // namespace OHOS
52 #endif  // OHOS_BUNDLE_MAP_H