1 /*
2  * Copyright (c) 2021 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_ABILITY_RUNTIME_APPLICATION_ENV_IMPL_H
17 #define OHOS_ABILITY_RUNTIME_APPLICATION_ENV_IMPL_H
18 
19 #include <string>
20 #include "nocopyable.h"
21 
22 /**
23  * L1 App_info define
24  */
25 #include <list>
26 #include <string>
27 
28 typedef struct {
29     std::string bundleName;
30     std::string srcPath;
31     std::string dataPath;
32     bool isNativeApp;
33     std::list<std::string> moduleNames;
34 } AppInfo;
35 
36 namespace OHOS {
37 namespace AppExecFwk {
38 struct ApplicationInfo;
39 class ApplicationEnvImpl : public NoCopyable {
40 public:
41     /**
42      * @brief Gets an instance of the applicationenvimpl class
43      * @param -
44      * @return instance indicates
45      */
GetInstance()46     static ApplicationEnvImpl *GetInstance()
47     {
48         static ApplicationEnvImpl instance;
49         return &instance;
50     }
51     /**
52      * @brief destructor
53      * @param -
54      * @return -
55      */
56     ~ApplicationEnvImpl() override = default;
57 
58     /**
59      * @brief Sets L1 information about the runtime environment of the application to which the
60      *        ability belongs, including the bundle name, source code path, and data path.
61      * @param appInfo
62      * @return void
63      */
64     void SetAppInfo(const AppInfo &appInfo);
65 
66     /**
67      * @brief Sets information about the runtime environment of the application to which the
68      *        ability belongs, including the bundle name, source code path, and data path.
69      * @param appInfo
70      * @return void
71      */
72     void SetAppInfo(const ApplicationInfo &appInfo);
73 
74     /**
75      * @brief Gets the bundlename of the application's runtime environment
76      * @param -
77      * @return bundleName
78      */
79     const std::string &GetBundleName() const;
80 
81     /**
82      * @brief Gets the SrcPath of the application's runtime environment
83      * @param -
84      * @return SrcPath
85      */
86     const std::string &GetSrcPath() const;
87 
88     /**
89      * @brief Gets the DataPath of the application's runtime environment
90      * @param -
91      * @return DataPath
92      */
93     const std::string &GetDataPath() const;
94 
95 private:
96     ApplicationEnvImpl() = default;
97 
98     std::string bundleName_;
99 
100     std::string srcPath_;
101 
102     std::string dataPath_;
103 
104     static ApplicationEnvImpl instance_;
105 };
106 }  // namespace AppExecFwk
107 }  // namespace OHOS
108 #endif  // OHOS_ABILITY_RUNTIME_APPLICATION_ENV_IMPL_H
109