PixelLightAPI  .
Parameters.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Parameters.h                                   *
00003  *
00004  *  Copyright (C) 2002-2012 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 __PLRENDERER_PARAMETERS_H__
00024 #define __PLRENDERER_PARAMETERS_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/String/String.h>
00032 #include <PLCore/Container/Array.h>
00033 #include <PLCore/Container/HashMap.h>
00034 #include "PLRenderer/PLRenderer.h"
00035 
00036 
00037 //[-------------------------------------------------------]
00038 //[ Namespace                                             ]
00039 //[-------------------------------------------------------]
00040 namespace PLRenderer {
00041 
00042 
00043 //[-------------------------------------------------------]
00044 //[ Forward declarations                                  ]
00045 //[-------------------------------------------------------]
00046 class Texture;
00047 class TextureBuffer;
00048 
00049 
00050 //[-------------------------------------------------------]
00051 //[ Classes                                               ]
00052 //[-------------------------------------------------------]
00053 /**
00054 *  @brief
00055 *    Abstract parameters interface
00056 *
00057 *  @note
00058 *    - This interface offers no 'create parameter' functions because on some implementations it is not possible
00059 *      to create new parameters 'from outside'
00060 */
00061 class Parameters {
00062 
00063 
00064     //[-------------------------------------------------------]
00065     //[ Public definitions                                    ]
00066     //[-------------------------------------------------------]
00067     public:
00068         /**
00069         *  @brief
00070         *    Parameter data types
00071         */
00072         enum EDataType {
00073             String          = 0,    /**< String */
00074             Integer         = 1,    /**< Integer 1 */
00075             Integer2        = 2,    /**< Integer 2 */
00076             Integer3        = 3,    /**< Integer 3 */
00077             Integer4        = 4,    /**< Integer 4 */
00078             Float           = 5,    /**< Float 1 */
00079             Float2          = 6,    /**< Float 2 */
00080             Float3          = 7,    /**< Float 3 */
00081             Float4          = 8,    /**< Float 4 */
00082             Double          = 9,    /**< Double 1 */
00083             Double2         = 10,   /**< Double 2 */
00084             Double3         = 11,   /**< Double 3 */
00085             Double4         = 12,   /**< Double 4 */
00086             Float3x3        = 13,   /**< Float3x3 matrix */
00087             Float3x4        = 14,   /**< Float3x4 matrix */
00088             Float4x4        = 15,   /**< Float4x4 matrix */
00089             Double4x4       = 16,   /**< Double4x4 matrix */
00090             TextureBuffer   = 17,   /**< Texture buffer */
00091             UnknownDataType = 18    /**< Unknown data type */
00092         };
00093 
00094 
00095     //[-------------------------------------------------------]
00096     //[ Public static functions                               ]
00097     //[-------------------------------------------------------]
00098     public:
00099         /**
00100         *  @brief
00101         *    Returns a data type as string
00102         *
00103         *  @param[in] nDataType
00104         *    Data type to return as string
00105         *
00106         *  @return
00107         *    The given data type as string
00108         */
00109         static PLRENDERER_API PLCore::String DataTypeToString(EDataType nDataType);
00110 
00111         /**
00112         *  @brief
00113         *    Returns a data type as number
00114         *
00115         *  @param[in] sDataType
00116         *    Data type to return as number
00117         *
00118         *  @return
00119         *    The given data type as number
00120         */
00121         static PLRENDERER_API EDataType DataTypeFromString(const PLCore::String &sDataType);
00122 
00123 
00124     //[-------------------------------------------------------]
00125     //[ Public virtual Parameters functions                   ]
00126     //[-------------------------------------------------------]
00127     public:
00128         /**
00129         *  @brief
00130         *    Returns whether there's a valid parameter with the given name or not
00131         *
00132         *  @param[in] sName
00133         *    Name of the parameter to check
00134         *
00135         *  @return
00136         *    'true' if there's a valid parameter with the given name, else 'false'
00137         */
00138         virtual bool IsParameter(const PLCore::String &sName) const = 0;
00139 
00140         //[-------------------------------------------------------]
00141         //[ Get/set parameters                                    ]
00142         //[-------------------------------------------------------]
00143         /**
00144         *  @brief
00145         *    Returns a parameter value as string (e.g. "1.0 5.4 0.21")
00146         *
00147         *  param[in] sName
00148         *    Name of the parameter to return the value from
00149         *
00150         *  @return
00151         *    The value of the parameter as string, empty string on error
00152         */
00153         virtual PLCore::String GetParameterString(const PLCore::String &sName) const = 0;
00154 
00155         /**
00156         *  @brief
00157         *    Sets a parameter value from a string (e.g. "1.0 5.4 0.21")
00158         *
00159         *  param[in] sName
00160         *    Name of the parameter to set
00161         *  param[in] sValue
00162         *    New parameter value
00163         *
00164         *  @return
00165         *    'true' if all went fine, else 'false' (maybe unknown parameter)
00166         */
00167         virtual bool SetParameterString(const PLCore::String &sName, const PLCore::String &sValue) = 0;
00168 
00169         // Integer
00170         virtual bool GetParameter1i(const PLCore::String &sName, int &nX) const = 0;
00171         virtual bool SetParameter1i(const PLCore::String &sName, int nX) = 0;
00172         // Integer2
00173         virtual bool GetParameter2i(const PLCore::String &sName, int &nX, int &nY) const = 0;
00174         virtual bool GetParameter2iv(const PLCore::String &sName, int nValue[]) const = 0;
00175         virtual bool SetParameter2i(const PLCore::String &sName, int nX, int nY) = 0;
00176         virtual bool SetParameter2iv(const PLCore::String &sName, const int nValue[]) = 0;
00177         // Integer3
00178         virtual bool GetParameter3i(const PLCore::String &sName, int &nX, int &nY, int &nZ) const = 0;
00179         virtual bool GetParameter3iv(const PLCore::String &sName, int nValue[]) const = 0;
00180         virtual bool SetParameter3i(const PLCore::String &sName, int nX, int nY, int nZ) = 0;
00181         virtual bool SetParameter3iv(const PLCore::String &sName, const int nValue[]) = 0;
00182         // Integer4
00183         virtual bool GetParameter4i(const PLCore::String &sName, int &nX, int &nY, int &nZ, int &nW) const = 0;
00184         virtual bool GetParameter4iv(const PLCore::String &sName, int nValue[]) const = 0;
00185         virtual bool SetParameter4i(const PLCore::String &sName, int nX, int nY, int nZ, int nW) = 0;
00186         virtual bool SetParameter4iv(const PLCore::String &sName, const int nValue[]) = 0;
00187         // Float
00188         virtual bool GetParameter1f(const PLCore::String &sName, float &fX) const = 0;
00189         virtual bool SetParameter1f(const PLCore::String &sName, float fX) = 0;
00190         // Float2
00191         virtual bool GetParameter2f(const PLCore::String &sName, float &fX, float &fY) const = 0;
00192         virtual bool GetParameter2fv(const PLCore::String &sName, float fValue[]) const = 0;
00193         virtual bool SetParameter2f(const PLCore::String &sName, float fX, float fY) = 0;
00194         virtual bool SetParameter2fv(const PLCore::String &sName, const float fValue[]) = 0;
00195         // Float3
00196         virtual bool GetParameter3f(const PLCore::String &sName, float &fX, float &fY, float &fZ) const = 0;
00197         virtual bool GetParameter3fv(const PLCore::String &sName, float fValue[]) const = 0;
00198         virtual bool SetParameter3f(const PLCore::String &sName, float fX, float fY, float fZ) = 0;
00199         virtual bool SetParameter3fv(const PLCore::String &sName, const float fValue[]) = 0;
00200         // Float4
00201         virtual bool GetParameter4f(const PLCore::String &sName, float &fX, float &fY, float &fZ, float &fW) const = 0;
00202         virtual bool GetParameter4fv(const PLCore::String &sName, float fValue[]) const = 0;
00203         virtual bool SetParameter4f(const PLCore::String &sName, float fX, float fY, float fZ, float fW) = 0;
00204         virtual bool SetParameter4fv(const PLCore::String &sName, const float fValue[]) = 0;
00205         // Double
00206         virtual bool GetParameter1d(const PLCore::String &sName, double &fX) const = 0;
00207         virtual bool SetParameter1d(const PLCore::String &sName, double fX) = 0;
00208         // Double2
00209         virtual bool GetParameter2d(const PLCore::String &sName, double &fX, double &fY) const = 0;
00210         virtual bool GetParameter2dv(const PLCore::String &sName, double fValue[]) const = 0;
00211         virtual bool SetParameter2d(const PLCore::String &sName, double fX, double fY) = 0;
00212         virtual bool SetParameter2dv(const PLCore::String &sName, const double fValue[]) = 0;
00213         // Double3
00214         virtual bool GetParameter3d(const PLCore::String &sName, double &fX, double &fY, double &fZ) const = 0;
00215         virtual bool GetParameter3dv(const PLCore::String &sName, double fValue[]) const = 0;
00216         virtual bool SetParameter3d(const PLCore::String &sName, double fX, double fY, double fZ) = 0;
00217         virtual bool SetParameter3dv(const PLCore::String &sName, const double fValue[]) = 0;
00218         // Double4
00219         virtual bool GetParameter4d(const PLCore::String &sName, double &fX, double &fY, double &fZ, double &fW) const = 0;
00220         virtual bool GetParameter4dv(const PLCore::String &sName, double fValue[]) const = 0;
00221         virtual bool SetParameter4d(const PLCore::String &sName, double fX, double fY, double fZ, double fW) = 0;
00222         virtual bool SetParameter4dv(const PLCore::String &sName, const double fValue[]) = 0;
00223         // Float3x3
00224         virtual bool GetParameterFloat3x3(const PLCore::String &sName, float fValue[]) const = 0;
00225         virtual bool SetParameterFloat3x3(const PLCore::String &sName, const float fValue[]) = 0;
00226         // Float3x4
00227         virtual bool GetParameterFloat3x4(const PLCore::String &sName, float fValue[]) const = 0;
00228         virtual bool SetParameterFloat3x4(const PLCore::String &sName, const float fValue[]) = 0;
00229         // Float4x4
00230         virtual bool GetParameterMatrixfv(const PLCore::String &sName, float fValue[]) const = 0;
00231         virtual bool SetParameterMatrixfv(const PLCore::String &sName, const float fValue[]) = 0;
00232         // Double4x4
00233         virtual bool GetParameterMatrixdv(const PLCore::String &sName, double fValue[]) const = 0;
00234         virtual bool SetParameterMatrixdv(const PLCore::String &sName, const double fValue[]) = 0;
00235         // Texture buffer
00236         /**
00237         *  @brief
00238         *    Returns the texture buffer of the parameter
00239         *
00240         *  @return
00241         *    The texture buffer of the parameter, can be a null pointer
00242         */
00243         virtual PLRenderer::TextureBuffer *GetParameterTextureBuffer(const PLCore::String &sName) const = 0;
00244 
00245         /**
00246         *  @brief
00247         *    Sets the texture buffer of the parameter
00248         *
00249         *  @param[in] sName
00250         *    Name of the parameter where to set the texture buffer
00251         *  @param[in] pTextureBuffer
00252         *    Texture buffer to set, can be a null pointer
00253         *
00254         *  @return
00255         *    Texture stage the texture buffer was set to, < 0 on error
00256         */
00257         virtual int SetParameterTextureBuffer(const PLCore::String &sName, PLRenderer::TextureBuffer *pTextureBuffer) = 0;
00258 
00259         /**
00260         *  @brief
00261         *    Returns the texture of the parameter
00262         *
00263         *  @return
00264         *    The texture of the parameter, can be a null pointer
00265         */
00266         virtual PLRenderer::Texture *GetParameterTexture(const PLCore::String &sName) const = 0;
00267 
00268         /**
00269         *  @brief
00270         *    Sets the texture of the parameter
00271         *
00272         *  @param[in] sName
00273         *    Name of the parameter where to set the texture
00274         *  @param[in] sFilename
00275         *    Texture filename
00276         *
00277         *  @return
00278         *    Texture stage the texture was set to, < 0 on error
00279         */
00280         virtual int SetParameterTexture(const PLCore::String &sName, const PLCore::String &sFilename) = 0;
00281 
00282         /**
00283         *  @brief
00284         *    Sets the texture of the parameter
00285         *
00286         *  @param[in] sName
00287         *    Name of the parameter where to set the texture
00288         *  @param[in] pTexture
00289         *    Texture to set, can be a null pointer
00290         *
00291         *  @return
00292         *    Texture stage the texture was set to, < 0 on error
00293         */
00294         virtual int SetParameterTexture(const PLCore::String &sName, PLRenderer::Texture *pTexture) = 0;
00295 
00296 
00297     //[-------------------------------------------------------]
00298     //[ Protected functions                                   ]
00299     //[-------------------------------------------------------]
00300     protected:
00301         /**
00302         *  @brief
00303         *    Constructor
00304         */
00305         PLRENDERER_API Parameters();
00306 
00307         /**
00308         *  @brief
00309         *    Destructor
00310         */
00311         PLRENDERER_API virtual ~Parameters();
00312 
00313 
00314     //[-------------------------------------------------------]
00315     //[ Private functions                                     ]
00316     //[-------------------------------------------------------]
00317     private:
00318         /**
00319         *  @brief
00320         *    Copy constructor
00321         *
00322         *  @param[in] cSource
00323         *    Source to copy from
00324         */
00325         Parameters(const Parameters &cSource);
00326 
00327         /**
00328         *  @brief
00329         *    Copy operator
00330         *
00331         *  @param[in] cSource
00332         *    Source to copy from
00333         *
00334         *  @return
00335         *    Reference to this instance
00336         */
00337         Parameters &operator =(const Parameters &cSource);
00338 
00339 
00340 };
00341 
00342 
00343 //[-------------------------------------------------------]
00344 //[ Namespace                                             ]
00345 //[-------------------------------------------------------]
00346 } // PLRenderer
00347 
00348 
00349 #endif // __PLRENDERER_PARAMETERS_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:57
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported