00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __SL_ENUM_H__
00025 #define __SL_ENUM_H__
00026
00027 #if defined(_WIN32) || defined (_WIN32_WCE) || defined(_XBOX)
00028
00029 #pragma warning( disable : 4786 )
00030 #endif // defined(_WIN32) || defined (_WIN32_WCE)
00031
00032 #include "SL_Int.h"
00033 #include "SL_String.h"
00034 #include "EnumDictionary.h"
00035
00037 template <class EnumType, SI_Int MaxValue>
00038 class XSIEXPORT CSLEnumProxy
00039 : public CSLAnimatableType
00040 {
00041 public:
00046 CSLEnumProxy(CdotXSITemplate *in_pTemplate, SI_Int in_nIndex );
00047
00052 CSLEnumProxy& operator =(const CSLEnumProxy &in_Value);
00053
00058 CSLEnumProxy& operator =(const EnumType &in_Value);
00059
00064 SI_Bool operator ==(const CSLEnumProxy &in_ToCompare);
00065
00070 SI_Bool operator ==(const EnumType &in_ToCompare);
00071
00073
00077 SI_Bool IsValid();
00078
00080
00083 operator EnumType();
00084
00088 virtual EElementType Type();
00089
00093 virtual SI_Float GetFloatValue();
00094
00098 virtual SI_Void SetFloatValue(SI_Float in_fValue);
00099
00105 virtual SI_Error Connect( CdotXSITemplate *in_pTemplate, SI_Int in_nIndex );
00106
00110 virtual CdotXSIParam* ParameterReference();
00111
00112 private:
00113 CSLEnumProxy( CSLEnumProxy &in_pBasicType ){}
00114 CSLIntProxy m_Value;
00115 };
00116
00118 template <class EnumType, SI_Int MaxValue>
00119 class CSLStrEnumProxy
00120 : public CSLAnimatableType
00121 {
00122 public:
00127 CSLStrEnumProxy(CdotXSITemplate *in_pTemplate, SI_Int in_nIndex, CEnumDictionary<EnumType, MaxValue> *in_pDictionary);
00128
00133 CSLStrEnumProxy& operator =(const CSLStrEnumProxy &in_Value);
00134
00139 CSLStrEnumProxy& operator =(const EnumType &in_Value);
00140
00146 SI_Bool operator ==(const CSLStrEnumProxy &in_ToCompare);
00147
00152 SI_Bool operator ==(const EnumType &in_ToCompare);
00153
00155
00159 SI_Bool IsValid();
00160
00162
00165 operator EnumType();
00166
00170 virtual EElementType Type();
00171
00175 virtual SI_Float GetFloatValue();
00176
00180 virtual SI_Void SetFloatValue(SI_Float in_fValue);
00181
00187 SI_Error Connect( CdotXSITemplate *in_pTemplate, SI_Int in_nIndex );
00188
00189 private:
00190 CSLStrEnumProxy( CSLStrEnumProxy &in_pBasicType ){}
00191
00192 CEnumDictionary<EnumType, MaxValue> *m_pDictionary;
00193 EnumType m_EnumValue;
00194 CSLStringProxy m_StringValue;
00195 };
00196
00197
00199
00201
00202 template <class EnumType, SI_Int MaxValue>
00203 CSLEnumProxy<EnumType,MaxValue>::CSLEnumProxy
00204 (
00205 CdotXSITemplate *in_pTemplate,
00206 SI_Int in_nIndex
00207 ) : m_Value(in_pTemplate, in_nIndex)
00208 {
00209 if ( in_pTemplate )
00210 Connect(in_pTemplate, in_nIndex );
00211 }
00212 template <class EnumType, SI_Int MaxValue>
00213 SI_Error CSLEnumProxy<EnumType,MaxValue>::Connect( CdotXSITemplate *in_pTemplate, SI_Int in_nIndex )
00214 {
00215 m_Value.Connect(in_pTemplate,in_nIndex);
00216 return 0;
00217 }
00218
00219
00220 template <class EnumType, SI_Int MaxValue>
00221 inline CSLEnumProxy<EnumType,MaxValue>& CSLEnumProxy<EnumType,MaxValue>::operator =
00222 (
00223 const CSLEnumProxy &in_Value
00224 )
00225 {
00226 m_Value = in_Value.m_Value;
00227 return *this;
00228 }
00229
00230 template <class EnumType, SI_Int MaxValue>
00231 inline CSLEnumProxy<EnumType,MaxValue>& CSLEnumProxy<EnumType,MaxValue>::operator =
00232 (
00233 const EnumType &in_Value
00234 )
00235 {
00236 m_Value = in_Value;
00237 return *this;
00238 }
00239
00240 template <class EnumType, SI_Int MaxValue>
00241 inline SI_Bool CSLEnumProxy<EnumType,MaxValue>::operator ==
00242 (
00243 const CSLEnumProxy<EnumType,MaxValue> &in_ToCompare
00244 )
00245 {
00246 return m_Value == in_ToCompare.m_Value;
00247 }
00248
00249 template <class EnumType, SI_Int MaxValue>
00250 inline SI_Bool CSLEnumProxy<EnumType,MaxValue>::operator ==
00251 (
00252 const EnumType &in_nToCompare
00253 )
00254 {
00255 return m_Value == in_nToCompare;
00256 }
00257
00258 template <class EnumType, SI_Int MaxValue>
00259 inline CSLEnumProxy<EnumType,MaxValue>::operator EnumType()
00260 {
00261 return (EnumType)((SI_Int)m_Value);
00262 }
00263
00264 template <class EnumType, SI_Int MaxValue>
00265 inline SI_Bool CSLEnumProxy<EnumType,MaxValue>::IsValid
00266 (
00267 )
00268 {
00269 return m_Value <= MaxValue;
00270 }
00271
00272 template <class EnumType, SI_Int MaxValue>
00273 CSLAnimatableType::EElementType CSLEnumProxy<EnumType,MaxValue>::Type
00274 (
00275 )
00276 {
00277 return SI_ENUM_TYPE;
00278 }
00279
00280 template <class EnumType, SI_Int MaxValue>
00281 SI_Float CSLEnumProxy<EnumType,MaxValue>::GetFloatValue
00282 (
00283 )
00284 {
00285 return (SI_Float) ( (SI_Int) m_Value);
00286 }
00287
00288 template <class EnumType, SI_Int MaxValue>
00289 SI_Void CSLEnumProxy<EnumType,MaxValue>::SetFloatValue
00290 (
00291 SI_Float in_fValue
00292 )
00293 {
00294 if(in_fValue <= MaxValue)
00295 {
00296 m_Value = (SI_Int) in_fValue;
00297 }
00298 }
00299
00300 template <class EnumType, SI_Int MaxValue>
00301 CdotXSIParam* CSLEnumProxy<EnumType,MaxValue>::ParameterReference()
00302 {
00303 return m_Value.ParameterReference();
00304 }
00305
00307
00308 template <class EnumType, SI_Int MaxValue>
00309 CSLStrEnumProxy<EnumType,MaxValue>::CSLStrEnumProxy
00310 (
00311 CdotXSITemplate *in_pTemplate,
00312 SI_Int in_nIndex,
00313 CEnumDictionary<EnumType, MaxValue> *in_pDictionary
00314 ) : m_StringValue(in_pTemplate, in_nIndex)
00315 , m_pDictionary(in_pDictionary)
00316 {
00317
00318 if (!m_pDictionary->ToEnum( m_EnumValue, m_StringValue ))
00319 {
00320
00321 m_EnumValue = (EnumType)(MaxValue + 1);
00322 }
00323 }
00324 template <class EnumType, SI_Int MaxValue>
00325 SI_Error CSLStrEnumProxy<EnumType,MaxValue>::Connect( CdotXSITemplate *in_pTemplate, SI_Int in_nIndex )
00326 {
00327 m_StringValue.Connect(in_pTemplate, in_nIndex);
00328 if (!m_pDictionary->ToEnum( m_EnumValue, m_StringValue ))
00329 {
00330
00331 m_EnumValue = (EnumType)(MaxValue + 1);
00332 }
00333
00334 return 0;
00335 }
00336
00337
00338 template <class EnumType, SI_Int MaxValue>
00339 inline CSLStrEnumProxy<EnumType,MaxValue>& CSLStrEnumProxy<EnumType,MaxValue>::operator =
00340 (
00341 const CSLStrEnumProxy &in_Value
00342 )
00343 {
00344 m_EnumValue = in_Value.m_EnumValue;
00345 m_StringValue = m_pDictionary->ToString( m_EnumValue );
00346
00347 return *this;
00348 }
00349
00350 template <class EnumType, SI_Int MaxValue>
00351 inline CSLStrEnumProxy<EnumType,MaxValue>& CSLStrEnumProxy<EnumType,MaxValue>::operator =
00352 (
00353 const EnumType &in_Value
00354 )
00355 {
00356 m_EnumValue = in_Value;
00357 m_StringValue = m_pDictionary->ToString( m_EnumValue );
00358
00359 return *this;
00360 }
00361
00362 template <class EnumType, SI_Int MaxValue>
00363 inline SI_Bool CSLStrEnumProxy<EnumType,MaxValue>::operator ==
00364 (
00365 const CSLStrEnumProxy<EnumType,MaxValue> &in_ToCompare
00366 )
00367 {
00368 return m_EnumValue == in_ToCompare.m_EnumValue;
00369 }
00370
00371 template <class EnumType, SI_Int MaxValue>
00372 inline SI_Bool CSLStrEnumProxy<EnumType,MaxValue>::operator ==
00373 (
00374 const EnumType &in_nToCompare
00375 )
00376 {
00377 return m_EnumValue == in_nToCompare;
00378 }
00379
00380 template <class EnumType, SI_Int MaxValue>
00381 inline CSLStrEnumProxy<EnumType,MaxValue>::operator EnumType()
00382 {
00383 return m_EnumValue;
00384 }
00385
00386 template <class EnumType, SI_Int MaxValue>
00387 inline SI_Bool CSLStrEnumProxy<EnumType,MaxValue>::IsValid
00388 (
00389 )
00390 {
00391 return m_EnumValue <= MaxValue;
00392 }
00393
00394 template <class EnumType, SI_Int MaxValue>
00395 CSLAnimatableType::EElementType CSLStrEnumProxy<EnumType,MaxValue>::Type
00396 (
00397 )
00398 {
00399 return SI_STRING_ENUM_TYPE;
00400 }
00401
00402 template <class EnumType, SI_Int MaxValue>
00403 SI_Float CSLStrEnumProxy<EnumType,MaxValue>::GetFloatValue
00404 (
00405 )
00406 {
00407 return (SI_Float) m_EnumValue;
00408 }
00409
00410 template <class EnumType, SI_Int MaxValue>
00411 SI_Void CSLStrEnumProxy<EnumType,MaxValue>::SetFloatValue
00412 (
00413 SI_Float in_fValue
00414 )
00415 {
00416 m_EnumValue = (EnumType) ( (SI_Int) in_fValue);
00417 m_StringValue = m_pDictionary->ToString( m_EnumValue );
00418 }
00419
00420 #endif //__SL_ENUM_H__