Tizen 2.0 Release
[framework/web/wrt-commons.git] / modules / widget_dao / include / dpl / wrt-dao-ro / feature_model.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    feature_model.h
18  * @author  Pawel Sikorski (p.sikorski@samgsung.com)
19  * @version
20  * @brief   This file contains FeatureModel, FeatureHandle definitions.
21  */
22 #ifndef FEATURE_MODEL_H
23 #define FEATURE_MODEL_H
24
25 #include <dpl/event/model.h>
26 #include <dpl/event/property.h>
27 #include <memory>
28 #include <string>
29 #include <list>
30 #include <set>
31 #include <dpl/wrt-dao-ro/common_dao_types.h>
32
33 namespace WrtDB {
34
35 typedef int FeatureHandle;
36 typedef std::list<FeatureHandle> FeatureHandleList;
37 typedef std::shared_ptr<FeatureHandleList> FeatureHandleListPtr;
38
39 typedef int FeatureSetHandle;
40 typedef std::list<FeatureSetHandle> FeatureSetHandleList;
41
42 typedef struct {
43     std::string     featureName;
44     DbPluginHandle  pluginHandle;
45 } FeatureData;
46
47 class FeatureModel : public DPL::Event::Model
48 {
49   public:
50     DPL::Event::Property<FeatureHandle, DPL::Event::PropertyReadOnly> FHandle;
51     DPL::Event::Property<std::string> Name;
52
53     DPL::Event::Property<std::set<std::string> > DeviceCapabilities;
54     DPL::Event::Property<DbPluginHandle> PHandle;
55
56     FeatureModel(FeatureHandle handle) :
57         FHandle(this, handle),
58         Name(this),
59         DeviceCapabilities(this),
60         PHandle(this, -1)
61     {
62     }
63
64     void SetData(const std::string& name, const std::set<std::string>& deviceCapabilities, const DbPluginHandle& pluginHandle)
65     {
66         Name.SetWithoutLock(name);
67         DeviceCapabilities.SetWithoutLock(deviceCapabilities);
68         PHandle.SetWithoutLock(pluginHandle);
69     }
70 };
71
72 typedef std::shared_ptr<FeatureModel> FeatureModelPtr;
73
74 } // namespace WrtDB
75
76 #endif // FEATURE_MODEL_H