Update wrt-plugins-common_0.3.53
[framework/web/wrt-plugins-common.git] / src / plugin-loading / plugin_model.cpp
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_model.cpp
18  * @author  Pawel Sikorski (p.sikorski@samgsung.com)
19  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samgsung.com)
20  * @author  Grzegorz Krawczyk (g.krawczyk@samgsung.com)
21  * @version
22  * @brief   This file contains PluginModel, PluginHandle definitions.
23  */
24
25 #include "plugin_model.h"
26 #include <dpl/event/model_bind_to_dao.h>
27 #include <dpl/wrt-dao-ro/feature_dao_read_only.h>
28
29 using namespace WrtDB;
30
31 template <typename RetType, RetType(PluginDAOReadOnly::*extFun) () const >
32 struct BindToPluginDAO :
33     DPL::Event::BindToDAO<PluginModel,
34                           RetType,
35                           WrtDB::DbPluginHandle,
36                           PluginDAOReadOnly,
37                           &PluginModel::getHandle,
38                           extFun>
39 {
40 };
41
42 template <typename RetType, RetType(*extFun) (WrtDB::DbPluginHandle)>
43 struct BindToFeatureDAOStatic :
44     DPL::Event::BindToDAO_Static<PluginModel,
45                                  RetType,
46                                  WrtDB::DbPluginHandle,
47                                  &PluginModel::getHandle,
48                                  extFun>
49 {
50 };
51
52 PluginModel::PluginModel(const WrtDB::DbPluginHandle& handle) :
53     Handle(this, handle),
54     LibraryName(this,
55                 BindToPluginDAO<std::string,
56                 &PluginDAOReadOnly::getLibraryName>::Get),
57     LibraryPath(this,
58                 BindToPluginDAO<std::string,
59                 &PluginDAOReadOnly::getLibraryPath>::Get),
60     FeatureHandles(this,
61                    BindToFeatureDAOStatic<FeatureHandleListPtr,
62                    FeatureDAOReadOnly::GetFeatureHandleListForPlugin>::Get),
63     LibraryDependencies(this,
64                         BindToPluginDAO<PluginHandleSetPtr,
65                         &PluginDAOReadOnly::getLibraryDependencies>::Get),
66     LibraryInstance(this, PluginPtr())
67 {
68 }
69
70 WrtDB::DbPluginHandle PluginModel::getHandle() const
71 {
72     return Handle.Get();
73 }
74
75 bool PluginModel::operator< (const PluginModel& obj) const
76 {
77     return obj.Handle.Get() < Handle.Get();
78 }