Refactoring ni_common.cc
[platform/core/dotnet/launcher.git] / NativeLauncher / installer-plugin / ni_common.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __NI_COMMON_H__
18 #define __NI_COMMON_H__
19
20 #include <functional>
21
22 typedef std::function<void (std::string)> afterCreate;
23
24 /**
25  * @brief : structure which contains directory info
26  */
27 typedef struct NiCommonOption {
28         std::string runtimeDir; /**< .NETCore Runtime directory */
29         std::string tizenFXDir; /**< TizenFX directory */
30         std::string extraDirs; /**< ":" seperated directories which can be set by plugins */
31 } NiCommonOption;
32
33 /**
34  * @brief initialize NICommon
35  * @param[in] options to initialize path
36  * @return 0 on success, otherwise a negative error value
37  */
38 int initNICommon(NiCommonOption* option);
39
40 /**
41  * @brief finalize NICommon
42  * @details Before re-initialize NICommon, you have to finalize current NICommon first.
43  */
44 void finalizeNICommon();
45
46 /**
47  * @brief create native images (NI file) for Platform DLLs (.NETCore + TizenFX)
48  */
49 void createNiPlatform(bool enableR2R);
50
51 /**
52  * @brief create native image for specific dll with file path.
53  * @param[i] dllPath file path to generate native image
54  * @param[i] enableR2R enable ready-to-run mode
55  * @return 0 on success, otherwise a negative error value
56  */
57 int createNiDll(const std::string& dllPath, bool enableR2R);
58
59 /**
60  * @brief create native images with files under specific directory.
61  * @param[i] rootPaths directories whicn contains DLLs
62  * @param[i] count number of rootPath
63  * @param[i] enableR2R enable ready-to-run mode
64  */
65 void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R);
66
67 /**
68  * @brief create native images for specific package. (All DLLs)
69  * @param[i] pkgId package ID
70  * @param[i] enableR2R enable ready-to-run mode
71  * @return 0 on success, otherwise a negative error value
72  */
73 int createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R);
74
75 /**
76  * @brief create native image for specific dll in the package.
77  * @Details All dlls in the package are added for reference when create native image.
78  * @param[i] pkgId package ID
79  * @param[i] enableR2R enable ready-to-run mode
80  * @return 0 on success, otherwise a negative error value
81  */
82 int createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R);
83
84 /**
85  * @brief remove native images (NI file) for Platform DLLs (.NETCore + TizenFX)
86  */
87 void removeNiPlatform();
88
89 /**
90  * @brief remove native images under specific directory.
91  * @param[i] rootPaths directories whicn contains native image
92  * @param[i] count number of rootPath
93  */
94 void removeNiUnderDirs(const std::string rootPaths[], int count);
95
96 /**
97  * @brief remove native images for specific package.
98  * @param[i] pkgId package ID
99  * @return 0 on success, otherwise a negative error value
100  */
101 int removeNiUnderPkgRoot(const std::string& pkgId);
102
103 /**
104  * @brief regenerate native image for all installed application
105  */
106 int regenerateAppNI(bool enableR2R);
107
108 #endif /* __NI_COMMON_H__ */