Implement launching 'metadata' and 'category' plugin
[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 <boost/filesystem/path.hpp>
9
10 #include <pkgmgrinfo_basic.h>
11 #include <string>
12 #include <vector>
13
14 #include "common/plugins/plugin.h"
15 #include "common/plugins/plugin_list_parser.h"
16 #include "common/plugins/plugin_xml_parser.h"
17
18 namespace common_installer {
19
20 /** this class manages XML and plugin lists */
21 class PluginManager {
22  public:
23   using PluginInfoList = std::vector<std::shared_ptr<PluginInfo>>;
24
25   PluginManager(const std::string& xml_path,
26                 const std::string& list_path,
27                 manifest_x* manifest)
28       : xml_parser_(xml_path),
29         list_parser_(list_path),
30         manifest_(manifest) {}
31
32   bool LoadPlugins();
33   void RunPlugins(Plugin::ActionType action_type);
34
35  private:
36   bool GenerateUnknownTagList(std::vector<std::string>* xml_tags);
37   bool GeneratePluginInfoList(PluginInfoList* plugin_info_list);
38
39   PluginsXmlParser xml_parser_;
40   PluginsListParser list_parser_;
41   manifest_x* manifest_;
42   std::vector<std::unique_ptr<Plugin>> loaded_plugins_;
43 };
44
45 }  // namespace common_installer
46
47 #endif  // COMMON_PLUGINS_PLUGIN_MANAGER_H_