lib
value.h
00001 /*************************************************************************** 00002 * value.h 00003 * This file is part of the KDE project 00004 * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 ***************************************************************************/ 00019 00020 #ifndef KROSS_API_VALUE_H 00021 #define KROSS_API_VALUE_H 00022 00023 #include <qstring.h> 00024 #include <qvariant.h> 00025 00026 #include "object.h" 00027 00028 namespace Kross { namespace Api { 00029 00037 template<class T, class V> 00038 class Value : public Object 00039 { 00040 public: 00041 00048 Value(V value) 00049 : Object() 00050 , m_value(value) {} 00051 00055 virtual ~Value() {} 00056 00057 //operator V&() const { return m_value; } 00058 00064 V& getValue() { return m_value; } 00065 //operator V& () { return m_value; } 00066 00067 template<typename TYPE> 00068 static Object::Ptr toObject(TYPE t) { return new T(t); } 00069 00070 #if 0 00071 //do we need it anyway? 00081 void setValue(V& value) { m_value = value; } 00082 #endif 00083 00084 private: 00085 V m_value; 00086 }; 00087 00088 }} 00089 00090 #endif 00091