[Release] wrt-plugins-common_0.3.76
[platform/framework/web/wrt-plugins-common.git] / src / plugin-loading / plugin_container_support.h
1 /*
2  * Copyright (c) 2011 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  * @file        plugin_container_support.h
18  * @author      Grzegorz Krawczyk (g.krawczyk@samsung.com)
19  * @version     1.0
20  */
21 #ifndef PLUGIN_CONTAINER_SUPPORT_H
22 #define PLUGIN_CONTAINER_SUPPORT_H
23
24 #include <memory>
25 #include <set>
26 #include <string>
27
28 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
29 #include <dpl/wrt-dao-ro/feature_model.h>
30
31 #include "plugin_model.h"
32
33 class PluginContainerSupport
34 {
35   public:
36     typedef std::list<WrtDB::FeatureModelPtr> FeaturesList;
37     typedef std::list<PluginModelPtr> PluginsList;
38
39   private:
40     // Standard features
41     typedef std::list<std::string> StandardFeatureList;
42
43     // Main feature list. Always equal to DB feature list
44     typedef std::set<WrtDB::FeatureModelPtr> FeatureModelContainer;
45
46     // Main plugin list. Always equal to DB plugin list
47     typedef std::set<PluginModelPtr> PluginModelsContainer;
48
49     StandardFeatureList m_standardFeatureList;
50
51     WrtDB::PluginHandleList m_rootPluginsList;
52
53     PluginModelsContainer m_pluginModels;
54
55     FeatureModelContainer m_featureModels;
56
57     bool m_initialized;
58
59   private:
60     // Reading
61     void readStandardFeaturesList();
62     void readRootPluginsList();
63
64     // Plugin models
65     typedef std::multimap<WrtDB::FeatureHandle, std::string> DeviceCapList;
66     void registerFeatureModel(WrtDB::FeatureHandle handle,
67                               WrtDB::FeatureData* data,
68                               DeviceCapList deviceCapabilities);
69
70     WrtDB::FeatureModelPtr getFeatureModel(const std::string &name) const;
71     WrtDB::FeatureModelPtr getFeatureModel(WrtDB::FeatureHandle handle) const;
72
73     PluginModelPtr getPluginModel(const WrtDB::FeatureModelPtr &feature) const;
74
75   public:
76     PluginContainerSupport();
77
78     bool isInitialized()
79     {
80         return m_initialized;
81     }
82     void Initialize(int widgetHandle);
83     void registerPluginModel(WrtDB::DbPluginHandle handle);
84     std::list<std::string> getAllowedFeatures(int widgetHandle) const;
85     void readAllowedPlugins(int widgetHandle);
86     void readRootPlugins(int widgetHandle);
87     FeaturesList getStandardFeatures() const;
88     PluginsList  getStandardPlugins() const;
89     PluginsList  getRootPlugins() const;
90     PluginsList  getPluginsList() const;
91
92     PluginModelPtr getPluginForFeature(const std::string& featureName);
93
94     PluginModelPtr getPluginModelById(WrtDB::DbPluginHandle handle) const;
95
96     ~PluginContainerSupport();
97 };
98
99 typedef std::shared_ptr<PluginContainerSupport> PluginContainerSupportPtr;
100
101 #endif // PLUGIN_CONTAINER_SUPPORT_H