Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_wearable / modules / tizen / Widget / Property.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  *
18  *
19  * @file       Property.h
20  * @author     Grzegorz Krawczyk (g.krawczyk@samsung.com)
21  * @version    0.1
22  * @brief
23  */
24
25 #ifndef WIDGET_PROPERTY_H_
26 #define WIDGET_PROPERTY_H_
27
28 #include <string>
29 #include <Commons/Exception.h>
30
31 namespace WrtDeviceApis {
32 namespace Widget {
33 template<typename T>
34 class Property
35 {
36   public:
37     explicit Property() :
38         m_value(),
39         m_valid(false)
40     {}
41
42     void setValue(const T& value)
43     {
44         m_value = value;
45         m_valid = true;
46     }
47
48     T getValue() const
49     {
50         if (!m_valid) {
51             Throw(Commons::PlatformException);
52         }
53         return m_value;
54     }
55
56     bool isValid() const
57     {
58         return m_valid;
59     }
60
61     virtual ~Property()
62     {}
63
64   private:
65     T m_value;
66     bool m_valid;
67 };
68
69 typedef Property<std::string> StringProperty;
70 typedef Property<unsigned int> UIntProperty;
71 }
72 }
73 #endif