# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

channel.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_CHANNEL_H
00027 #define NL_CHANNEL_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/animated_value.h"
00031 
00032 namespace NL3D 
00033 {
00034 
00035 
00043 class IChannel
00044 {
00045 public:
00046 
00052         virtual const IAnimatedValue& getValue (const IAnimatedValue& value) const=0;
00053 
00059         virtual IAnimatedValue& getValue ()=0;
00060 
00062         virtual const IAnimatedValue& getDefaultValue () const=0;
00063 
00065 
00067         const std::string& getName () const
00068         {
00069                 return _Name;
00070         }
00071 
00073         void setName (const std::string& name)
00074         {
00075                 _Name=name;
00076         }
00077         
00078 private:
00079         // The name of the channel
00080         std::string             _Name;
00081 };
00082 
00083 
00091 template<class T>
00092 class CChannelBlendable : public IChannel
00093 {
00094 public:
00095 
00097         virtual void setValue (const IAnimatedValue& value)
00098         {
00099                 // Check good type !!
00100                 nlassert (typeid (_DefaultValue)==typeid (value));
00101 
00102                 // Ok assign!
00103                 _Value=*(CAnimatedValueBlendable<T>*)&value;
00104         }
00105 
00107         virtual const IAnimatedValue& getValue (const IAnimatedValue& value) const
00108         {
00109                 return _Value;
00110         }
00111 
00113         virtual IAnimatedValue& getValue ()
00114         {
00115                 return _Value;
00116         }
00117 
00119         const IAnimatedValue& getDefaultValue () const
00120         {
00121                 return _DefaultValue;
00122         }
00123 private:
00124         // The value of the channel
00125         CAnimatedValueBlendable<T>      _Value;
00126 
00127         // The default value of the channel
00128         CAnimatedValueBlendable<T>      _DefaultValue;
00129 };
00130 
00131 
00139 template<class T>
00140 class CChannelNotBlendable : public IChannel
00141 {
00142 public:
00143 
00145         virtual void setValue (const IAnimatedValue& value)
00146         {
00147                 // Check good type !!
00148                 nlassert (typeid (_DefaultValue)==typeid (value));
00149 
00150                 // Ok assign!
00151                 _Value=*(CAnimatedValueNotBlendable<T>*)&value;
00152         }
00153 
00155         virtual const IAnimatedValue& getValue (const IAnimatedValue& value) const
00156         {
00157                 return _Value;
00158         }
00159 
00161         virtual IAnimatedValue& getValue ()
00162         {
00163                 return _Value;
00164         }
00165 
00167         const IAnimatedValue& getDefaultValue () const
00168         {
00169                 return _DefaultValue;
00170         }
00171 private:
00172         // The value of the channel
00173         CAnimatedValueNotBlendable<T>   _Value;
00174 
00175         // The default value of the channel
00176         CAnimatedValueNotBlendable<T>   _DefaultValue;
00177 };
00178 
00179 
00180 typedef CChannelNotBlendable<bool> CChannelBool;
00181 typedef CChannelBlendable<int> CChannelInt;
00182 typedef CChannelBlendable<float> CChannelFloat;
00183 typedef CChannelBlendable<NLMISC::CVector> CChannelVector;
00184 typedef CChannelBlendable<NLMISC::CQuat> CChannelQuat;
00185 typedef CChannelNotBlendable<std::string> CChannelString;
00186 
00187 
00188 } // NL3D
00189 
00190 
00191 #endif // NL_CHANNEL_H
00192 
00193 /* End of channel.h */