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_APPLICATION_ENV_IMPL_H 17 #define OHOS_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 39 struct ApplicationInfo; 40 class ApplicationEnvImpl : public NoCopyable { 41 42 public: 43 /** 44 * @brief Gets an instance of the applicationenvimpl class 45 * @param - 46 * @return instance indicates 47 */ GetInstance()48 static ApplicationEnvImpl *GetInstance() 49 { 50 static ApplicationEnvImpl instance; 51 return &instance; 52 } 53 /** 54 * @brief destructor 55 * @param - 56 * @return - 57 */ 58 ~ApplicationEnvImpl() override = default; 59 60 /** 61 * @brief Sets L1 information about the runtime environment of the application to which the 62 * ability belongs, including the bundle name, source code path, and data path. 63 * @param appInfo 64 * @return void 65 */ 66 void SetAppInfo(const AppInfo &appInfo); 67 68 /** 69 * @brief Sets information about the runtime environment of the application to which the 70 * ability belongs, including the bundle name, source code path, and data path. 71 * @param appInfo 72 * @return void 73 */ 74 void SetAppInfo(const ApplicationInfo &appInfo); 75 76 /** 77 * @brief Gets the bundlename of the application's runtime environment 78 * @param - 79 * @return bundleName 80 */ 81 const std::string &GetBundleName() const; 82 83 /** 84 * @brief Gets the SrcPath of the application's runtime environment 85 * @param - 86 * @return SrcPath 87 */ 88 const std::string &GetSrcPath() const; 89 90 /** 91 * @brief Gets the DataPath of the application's runtime environment 92 * @param - 93 * @return DataPath 94 */ 95 const std::string &GetDataPath() const; 96 97 private: 98 ApplicationEnvImpl() = default; 99 100 std::string bundleName_; 101 102 std::string srcPath_; 103 104 std::string dataPath_; 105 106 static ApplicationEnvImpl instance_; 107 }; 108 109 } // namespace AppExecFwk 110 } // namespace OHOS 111 #endif // OHOS_APPLICATION_ENV_IMPL_H 112