PixelLightAPI  .
DynFunc.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: DynFunc.h                                      *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLCORE_DYNFUNC_H__
00024 #define __PLCORE_DYNFUNC_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLCore/Core/SmartPtr.h"
00032 #include "PLCore/Base/Func/DynSignature.h"
00033 
00034 
00035 //[-------------------------------------------------------]
00036 //[ Namespace                                             ]
00037 //[-------------------------------------------------------]
00038 namespace PLCore {
00039 
00040 
00041 //[-------------------------------------------------------]
00042 //[ Forward declarations                                  ]
00043 //[-------------------------------------------------------]
00044 class FuncDesc;
00045 class DynParams;
00046 class XmlElement;
00047 
00048 
00049 //[-------------------------------------------------------]
00050 //[ Classes                                               ]
00051 //[-------------------------------------------------------]
00052 /**
00053 *  @brief
00054 *    Virtual base class for function objects (functoids)
00055 *
00056 *  @remarks
00057 *    This is the virtual base class to access functions and function objects dynamically.
00058 *    It is a virtual interface that allows you to call a function or function like object
00059 *    regardless of it's actual type (e.g. static function, method of an object or function object).
00060 */
00061 class DynFunc : public DynSignature {
00062 
00063 
00064     //[-------------------------------------------------------]
00065     //[ Public functions                                      ]
00066     //[-------------------------------------------------------]
00067     public:
00068         /**
00069         *  @brief
00070         *    Destructor
00071         */
00072         PLCORE_API virtual ~DynFunc();
00073 
00074 
00075     //[-------------------------------------------------------]
00076     //[ Public virtual DynFunc functions                      ]
00077     //[-------------------------------------------------------]
00078     public:
00079         /**
00080         *  @brief
00081         *    Get function descriptor
00082         *
00083         *  @return
00084         *    Descriptor (can be a null pointer)
00085         */
00086         PLCORE_API virtual const FuncDesc *GetDesc() const;
00087 
00088         /**
00089         *  @brief
00090         *    Call function
00091         *
00092         *  @param[in] cParams
00093         *    Parameters
00094         */
00095         PLCORE_API virtual void Call(DynParams &cParams);
00096 
00097         /**
00098         *  @brief
00099         *    Call function
00100         *
00101         *  @param[in] cParams
00102         *    Parameters
00103         */
00104         PLCORE_API virtual void Call(const DynParams &cParams);
00105 
00106         /**
00107         *  @brief
00108         *    Call function
00109         *
00110         *  @param[in] sParams
00111         *    Parameters as string
00112         */
00113         PLCORE_API virtual void Call(const String &sParams);
00114 
00115         /**
00116         *  @brief
00117         *    Call function
00118         *
00119         *  @param[in] cElement
00120         *    Parameters as XML
00121         */
00122         PLCORE_API virtual void Call(const XmlElement &cElement);
00123 
00124         /**
00125         *  @brief
00126         *    Call function with return as string
00127         *
00128         *  @param[in] sParams
00129         *    Parameters as string
00130         *
00131         *  @return
00132         *    Return of the function as string, empty string if there's no return
00133         */
00134         PLCORE_API virtual String CallWithReturn(const String &sParams);
00135 
00136         /**
00137         *  @brief
00138         *    Call function with return as string
00139         *
00140         *  @param[in] cElement
00141         *    Parameters as XML
00142         *
00143         *  @return
00144         *    Return of the function as string, empty string if there's no return
00145         */
00146         PLCORE_API virtual String CallWithReturn(const XmlElement &cElement);
00147 
00148         /**
00149         *  @brief
00150         *    Clone function object
00151         *
00152         *  @return
00153         *    Copy of this functoid (can be a null pointer!)
00154         */
00155         PLCORE_API virtual DynFunc *Clone() const;
00156 
00157 
00158     //[-------------------------------------------------------]
00159     //[ Protected functions                                   ]
00160     //[-------------------------------------------------------]
00161     protected:
00162         /**
00163         *  @brief
00164         *    Default constructor
00165         */
00166         PLCORE_API DynFunc();
00167 
00168         /**
00169         *  @brief
00170         *    Copy constructor
00171         *
00172         *  @param[in] cDynFunc
00173         *    Source to copy from
00174         */
00175         PLCORE_API DynFunc(const DynFunc &cDynFunc);
00176 
00177         /**
00178         *  @brief
00179         *    Copy operator
00180         *
00181         *  @param[in] cDynFunc
00182         *    Source to copy from
00183         *
00184         *  @return
00185         *    Reference to this instance
00186         */
00187         PLCORE_API DynFunc &operator =(const DynFunc &cDynFunc);
00188 
00189 
00190 };
00191 
00192 
00193 //[-------------------------------------------------------]
00194 //[ Type definitions                                      ]
00195 //[-------------------------------------------------------]
00196 typedef SmartPtr<DynFunc> DynFuncPtr;
00197 
00198 
00199 //[-------------------------------------------------------]
00200 //[ Namespace                                             ]
00201 //[-------------------------------------------------------]
00202 } // PLCore
00203 
00204 
00205 #endif // __PLCORE_DYNFUNC_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:52
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported