argument.h

00001 /***************************************************************************
00002  * argument.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_ARGUMENT_H
00021 #define KROSS_API_ARGUMENT_H
00022 
00023 #include <qstring.h>
00024 #include <qvaluelist.h>
00025 
00026 #include "object.h"
00027 
00028 namespace Kross { namespace Api {
00029 
00030     // Forward declaration.
00031     class ArgumentList;
00032 
00033     /**
00034      * Each \a Class::Function holds a list of arguments
00035      * the function supports. The Argument-class represents
00036      * such a single argument in a \a ArgumentList collection.
00037      */
00038     class Argument
00039     {
00040         public:
00041 
00042             /**
00043              * Constructor.
00044              *
00045              * \param classname The name of the class this
00046              *        argument expects.
00047              * \param object The optional default \a Object this
00048              *        class holds.
00049              * \param visible defines if the @a Argument is visible
00050              *        to scripting-languages. If the argument is
00051              *        hidden, it's somewhat 'const' and cant be
00052              *        changed by scripting code. In that case the
00053              *        argument won't be even visible by scripting
00054              *        languages.
00055              */
00056             explicit Argument(const QString& classname = QString::null /*, Object::Ptr object = 0, bool visible = true*/ );
00057 
00058             /**
00059              * Destructor.
00060              */
00061             ~Argument();
00062 
00063             /**
00064              * Return the name of the class this argument expects.
00065              *
00066              * \return Name of the class this argument expects.
00067              */
00068             const QString& getClassName();
00069 
00070             /**
00071              * Return the optional default \a Object this class
00072              * holds.
00073              *
00074              * \return The default object or NULL if the argument
00075              *         isn't optional and therefore doesn't have
00076              *         an default object.
00077              */
00078             //Object::Ptr getObject() const;
00079 
00080             /**
00081              * \return true if the \a Argument should be hidden
00082              * to the scripting backend.
00083              */
00084             //bool isVisible() const;
00085 
00086             /**
00087              * Implementation of the << operator.
00088              *
00089              * \param arglist The \a ArgumentList the
00090              *        operator is applied on.
00091              * \return The changed \a ArgumentList.
00092              *
00093              * \todo Document where this argument is added in the list
00094              *       and add a brief code example.
00095              */
00096             ArgumentList& operator << (ArgumentList& arglist);
00097 
00098         private:
00099             /// The classname of the argument.
00100             QString m_classname;
00101             /// The optional default \a Object this argument holds.
00102             //Object::Ptr m_object;
00103             /// Defines if the argument is visible to the user.
00104             //bool m_visible;
00105     };
00106 
00107     /**
00108      * An ArgumentList is a collection of \a Argument
00109      * objects used in a \a Class::Function.
00110      */
00111     class ArgumentList
00112     {
00113         public:
00114 
00115             /**
00116              * Constructor.
00117              */
00118             ArgumentList();
00119 
00120             /**
00121              * Destructor.
00122              */
00123             ~ArgumentList();
00124 
00125             /**
00126              * Operator to return the list of arguments call-by-reference
00127              * to let code like the \a Callable::checkArguments method
00128              * enable manipulate those list.
00129              *
00130              * \return List of \a Argument instances.
00131              */
00132             operator QValueList<Argument>& () { return m_arguments; }
00133 
00134             /**
00135              * Implementation of the << operator.
00136              *
00137              * \param arg The passed \a Argument.
00138              * \return The changed \a ArgumentList.
00139              */
00140             ArgumentList& operator << (const Argument& arg);
00141 
00142             /**
00143              * Return number of minimal needed parameters.
00144              *
00145              * \return Minimal needed parameters.
00146              */
00147             //uint getMinParams() const;
00148 
00149             /**
00150              * Return the number of maximal allowed parameters.
00151              *
00152              * \return Maximal needed parameters.
00153              */
00154             //uint getMaxParams() const;
00155 
00156             /**
00157              * \return a string of the classnames each argument in the
00158              * argumentlist has. Mainly used foir debugging.
00159              */
00160             //QString toString();
00161 
00162         private:
00163             /// Minimal needed parameters.
00164             //uint m_minparams;
00165             /// Maximal needed parameters.
00166             //uint m_maxparams;
00167             /// List of \a Argument.
00168             QValueList<Argument> m_arguments;
00169     };
00170 
00171 }}
00172 
00173 #endif
00174 

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