2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef _ABSTRACTPROPERTYTYPE_H_
20 #define _ABSTRACTPROPERTYTYPE_H_
25 #include <boost/any.hpp>
26 #include <boost/lexical_cast.hpp>
28 class AbstractPropertyType
31 virtual std::string toString() = 0;
33 void setValue(boost::any val)
41 return boost::any_cast<T>(mValue);
56 class BasicPropertyType: public AbstractPropertyType
59 BasicPropertyType(BasicPropertyType const &other)
61 setValue(other.value<T>());
64 BasicPropertyType & operator = (BasicPropertyType const & other)
66 setValue(other.value<T>());
70 BasicPropertyType(T val)
71 :AbstractPropertyType()
76 BasicPropertyType(std::string val)
78 if(!val.empty() && val != "")
79 setValue(boost::lexical_cast<T,std::string>(val));
80 else throw std::runtime_error("value cannot be empty");
83 std::string toString()
85 std::stringstream stream;
92 class StringPropertyType: public AbstractPropertyType
95 StringPropertyType(std::string val)
96 :AbstractPropertyType()
101 StringPropertyType(StringPropertyType const & other)
103 setValue(other.value<std::string>());
106 StringPropertyType & operator = (StringPropertyType const & other)
108 setValue(other.value<std::string>());
113 std::string toString()
115 return value<std::string>();