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 //#include <kdebug.h>
00026 
00027 #include "object.h"
00028 
00029 namespace Kross { namespace Api {
00030 
00031     /**
00032      * Template class to represent values.
00033      *
00034      * Classes like \a Variant or \a List are implementing this
00035      * class. That way we have a common base for all kind of
00036      * values.
00037      */
00038     template<class T, class V>
00039     class Value : public Object
00040     {
00041         public:
00042 
00043             /**
00044              * Constructor.
00045              *
00046              * \param value The initial value this
00047              *        Value has.
00048              * \param name The name this Value has.
00049              */
00050             Value(V value, const QString& name)
00051                 : Object(name)
00052                 , m_value(value) {}
00053 
00054             /**
00055              * Destructor.
00056              */
00057             virtual ~Value() {}
00058 
00059             //operator V&() const { return m_value; }
00060 
00061             /**
00062              * Return the value.
00063              *
00064              * \return The value this Value-class holds.
00065              */
00066             V& getValue() { return m_value; }
00067             //operator V& () { return m_value; }
00068 
00069 #if 0
00070 //do we need it anyway?
00071             /**
00072              * Set the value.
00073              * The value is call-by-value cause it may
00074              * contain some KShared and therefore
00075              * we need to keep a local copy to keep
00076              * it from disappearing.
00077              *
00078              * \param value The value to set.
00079              */
00080             void setValue(V& value) { m_value = value; }
00081 #endif
00082 
00083         private:
00084             V m_value;
00085     };
00086 
00087 }}
00088 
00089 #endif
00090 

Generated on Thu Feb 9 17:59:11 2006 for Kross by  doxygen 1.4.6