added missings
authorKevron Rees <tripzero.kev@gmail.com>
Tue, 28 Aug 2012 23:06:19 +0000 (16:06 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Tue, 28 Aug 2012 23:06:19 +0000 (16:06 -0700)
lib/abstractpropertytype.cpp [new file with mode: 0644]
lib/abstractpropertytype.h [new file with mode: 0644]

diff --git a/lib/abstractpropertytype.cpp b/lib/abstractpropertytype.cpp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h
new file mode 100644 (file)
index 0000000..2ded031
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+       Copyright (C) 2012  Intel Corporation
+
+       This library is free software; you can redistribute it and/or
+       modify it under the terms of the GNU Lesser General Public
+       License as published by the Free Software Foundation; either
+       version 2.1 of the License, or (at your option) any later version.
+
+       This library is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+       Lesser General Public License for more details.
+
+       You should have received a copy of the GNU Lesser General Public
+       License along with this library; if not, write to the Free Software
+       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef _ABSTRACTPROPERTYTYPE_H_
+#define _ABSTRACTPROPERTYTYPE_H_
+
+#include <string>
+#include <sstream>
+#include <boost/any.hpp>
+
+class AbstractPropertyType
+{
+public:
+       virtual std::string toString()
+       {
+               return "";
+       }
+
+       void setValue(boost::any val)
+       {
+               mValue = val;
+       }
+
+       template <typename T>
+       T value()
+       {
+               return boost::any_cast<T>(mValue);
+       }
+
+protected:
+
+       boost::any mValue;
+
+};
+
+template <typename T>
+class BasicPropertyType: public AbstractPropertyType
+{
+public:
+       BasicPropertyType(BasicPropertyType const &other)
+       {
+               setValue(other.value<T>());
+       }
+
+       BasicPropertyType & operator = (BasicPropertyType const & other)
+       {
+               setValue(other.value<T>());
+               return *this;
+       }
+
+       BasicPropertyType(T val)
+               :AbstractPropertyType()
+       {
+               setValue(val);
+       }
+
+       std::string toString()
+       {
+               std::stringstream stream;
+               stream<<value<T>();
+
+               return stream.str();
+       }
+};
+
+#endif