Remove boost dependency
[platform/core/appfw/app-installers.git] / src / common / plugins / plugin_manager.h
1 // Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMMON_PLUGINS_PLUGIN_MANAGER_H_
6 #define COMMON_PLUGINS_PLUGIN_MANAGER_H_
7
8 #include <pkgmgrinfo_basic.h>
9
10 #include <filesystem>
11 #include <memory>
12 #include <string>
13 #include <vector>
14
15 #include "common/utils/pkgmgr_query.h"
16 #include "common/plugins/plugin.h"
17 #include "common/plugins/plugin_list_parser.h"
18 #include "common/plugins/plugin_xml_parser.h"
19
20 namespace common_installer {
21
22 /** this class manages XML and plugin lists */
23 class PluginManager {
24  public:
25   using PluginInfoList = std::vector<std::shared_ptr<PluginInfo>>;
26
27   PluginManager(const std::filesystem::path& xml_path,
28                 const std::filesystem::path& list_path,
29                 const std::string& pkgid,
30                 manifest_x* manifest,
31                 uid_t uid)
32       : xml_parser_(xml_path),
33         list_parser_(list_path),
34         pkgid_(pkgid),
35         manifest_(manifest),
36         uid_(uid) {}
37
38   bool LoadPlugins(Plugin::ActionType action_type);
39   bool RunPlugins(Plugin::ActionType action_type);
40
41  private:
42   bool IsDataRemoved(const char* data_type,
43                      const std::string& data);
44   bool GenerateUnknownTagList(std::vector<std::string>* xml_tags);
45   bool GeneratePluginInfoList(PluginInfoList* plugin_info_list);
46
47   PluginsXmlParser xml_parser_;
48   PluginsListParser list_parser_;
49   std::string pkgid_;
50   manifest_x* manifest_;
51   uid_t uid_;
52   std::vector<std::unique_ptr<Plugin>> loaded_plugins_;
53 };
54
55 }  // namespace common_installer
56
57 #endif  // COMMON_PLUGINS_PLUGIN_MANAGER_H_