# xsi_value.h

Go to the documentation of this file.

    00001 //*****************************************************************************
    00011 //*****************************************************************************
    00012
    00013 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
    00014 #pragma once
    00015 #endif
    00016
    00017 #ifndef __XSIVALUE_H__
    00018 #define __XSIVALUE_H__
    00019
    00020 #include "sicppsdk.h"
    00021 #include "xsi_ref.h"
    00022
    00023 namespace XSI {
    00024
    00025 class CLongArray;
    00026 class CFloatArray;
    00027 class CValueArray;
    00028
    00029 namespace MATH {
    00030     class CVector3;
    00031     class CVector2f;
    00032     class CVector3f;
    00033     class CVector4f;
    00034     class CQuaternionf;
    00035     class CRotationf;
    00036     class CMatrix3f;
    00037     class CMatrix4f;
    00038     class CColor4f;
    00039     class CShape;
    00040 };
    00041
    00042 //*****************************************************************************
    00157 //*****************************************************************************
    00158
    00159 class SICPPSDKDECL CValue
    00160 {
    00161 public:
    00162     typedef void* siPtrType;
    00163
    00165     enum DataType
    00166     {
    00167         siEmpty = 0,
    00168         siInt2 = 2,
    00169         siInt4 = 3,
    00170         siInt8 = 10,
    00171         siFloat = 4,
    00172         siDouble = 5,
    00173         siString = 8,
    00174         siIDispatch = 9,
    00179         siBool = 11,
    00180         siIUnknown = 13,
    00183         siInt1 = 16,
    00184         siUInt1 = 17,
    00185         siUInt2 = 18,
    00186         siUInt4 = 19,
    00187         siUInt8 = 20,
    00188         siWStr  = 31,
    00190         siRef = 666,
    00191         siArray,
    00192         siPtr,
    00193         siRefArray,
    00194         siVector3,
    00195         siLongArray,
    00196         siFloatArray,
    00197         siVector2f=800,
    00198         siVector3f,
    00199         siVector4f,
    00200         siQuaternionf,
    00201         siRotationf,
    00202         siMatrix3f,
    00203         siMatrix4f,
    00204         siColor4f,
    00205         siShape
    00206     };
    00207
    00235     union ValueField
    00236     {
    00237         short               sval;
    00238         LONG                lval;
    00239         float               fval;
    00240         double              dval;
    00241         bool                bval;
    00242         wchar_t*            pwval;
    00243         siPtrType           pval;
    00244         signed char         cval;
    00245         unsigned char       ucval;
    00246         CValueArray*        paval;
    00247         CLongArray*         plaval;
    00248         CFloatArray*        pfaval;
    00249         unsigned short      usval;
    00250         ULONG               ulval;
    00251         MATH::CVector2f*    pv2f;
    00252         MATH::CVector3f*    pv3f;
    00253         MATH::CVector4f*    pv4f;
    00254         MATH::CQuaternionf* pqf;
    00255         MATH::CRotationf*   prf;
    00256         MATH::CMatrix3f*    pm3f;
    00257         MATH::CMatrix4f*    pm4f;
    00258         MATH::CColor4f*     pc4f;
    00259         MATH::CShape*       pshp;
    00260         LLONG               llval;
    00261         ULLONG              ullval;
    00262     }m_u;
    00263     DataType m_t;
    00264
    00266     CValue();
    00267
    00269     virtual ~CValue();
    00270
    00274     CValue(const CValue& valSrc);
    00275
    00279     CValue(short valSrc);
    00280
    00284     CValue(unsigned short valSrc);
    00285
    00289     CValue(LONG valSrc);
    00290
    00291 #if !defined(linux) || !defined(__x86_64)
    00292
    00295     CValue(int valSrc);
    00296 #endif
    00297
    00301     CValue(ULONG valSrc);
    00302
    00307     CValue(LLONG valSrc);
    00308
    00313     CValue(ULLONG valSrc);
    00314
    00318     CValue(float valSrc);
    00319
    00323     CValue(double valSrc);
    00324
    00328     CValue(bool valSrc);
    00329
    00333     CValue(const CString& valSrc);
    00334
    00338     CValue(const CRef& valSrc);
    00339
    00344     CValue(const CRefArray& valSrc);
    00345
    00349     CValue(unsigned char valSrc);
    00350
    00354     CValue(signed char valSrc);
    00355
    00359     CValue(const CValueArray& valSrc);
    00360
    00365     CValue(const CLongArray& valSrc);
    00366
    00371     CValue(const CFloatArray& valSrc);
    00372
    00377     CValue(const MATH::CVector3& valSrc);
    00378
    00383     CValue(const MATH::CVector2f& valSrc);
    00384
    00389     CValue(const MATH::CVector3f& valSrc);
    00390
    00395     CValue(const MATH::CVector4f& val);
    00396
    00401     CValue(const MATH::CQuaternionf& val);
    00402
    00407     CValue(const MATH::CRotationf& val);
    00408
    00413     CValue(const MATH::CMatrix3f& val);
    00414
    00419     CValue(const MATH::CMatrix4f& val);
    00420
    00425     CValue(const MATH::CColor4f& val);
    00426
    00431     CValue(const MATH::CShape& val);
    00432
    00436     CValue(siPtrType valSrc);
    00437
    00441     CValue(const wchar_t* valSrc);
    00442
    00446     CValue& operator=(const CValue& valSrc);
    00447
    00451     CValue& operator=(short valSrc);
    00452
    00456     CValue& operator=(unsigned short valSrc);
    00457
    00461     CValue& operator=(LONG valSrc);
    00462
    00463 #if !defined(linux) || !defined(__x86_64)
    00464
    00467     CValue& operator=(int valSrc);
    00468 #endif
    00469
    00473     CValue& operator=(ULONG valSrc);
    00474
    00479     CValue& operator=(LLONG valSrc);
    00480
    00485     CValue& operator=(ULLONG valSrc);
    00486
    00490     CValue& operator=(float valSrc);
    00491
    00495     CValue& operator=(double valSrc);
    00496
    00500     CValue& operator=(bool valSrc);
    00501
    00505     CValue& operator=(const CString& valSrc);
    00506
    00510     CValue& operator=(const wchar_t * valSrc );
    00511
    00515     CValue& operator=(const CRef& valSrc);
    00516
    00521     CValue& operator=(const CRefArray& valSrc);
    00522
    00527     CValue& operator=(const MATH::CVector3& valSrc);
    00528
    00533     CValue& operator=(const MATH::CVector2f& valSrc);
    00534
    00539     CValue& operator=(const MATH::CVector3f& valSrc);
    00540
    00545     CValue& operator=(const MATH::CVector4f& valSrc);
    00546
    00551     CValue& operator=(const MATH::CMatrix3f& valSrc);
    00552
    00557     CValue& operator=(const MATH::CMatrix4f& valSrc);
    00558
    00563     CValue& operator=(const MATH::CRotationf& valSrc);
    00564
    00569     CValue& operator=(const MATH::CQuaternionf& valSrc);
    00570
    00575     CValue& operator=(const MATH::CColor4f& valSrc);
    00576
    00581     CValue& operator=(const MATH::CShape& valSrc);
    00582
    00586     CValue& operator=(unsigned char valSrc);
    00587
    00591     CValue& operator=(signed char valSrc);
    00592
    00596     CValue& operator=(const CValueArray& valSrc);
    00597
    00601     CValue& operator=(const CLongArray& valSrc);
    00602
    00606     CValue& operator=(const CFloatArray& valSrc);
    00607
    00611     CValue& operator=(siPtrType valSrc);
    00612
    00614     operator short () const;
    00616     operator unsigned short () const;
    00618     operator LONG () const;
    00619
    00620 #if !defined(linux) || !defined(__x86_64)
    00621
    00624     operator int () const;
    00625 #endif
    00626
    00630     operator ULONG () const;
    00631
    00635     operator LLONG () const;
    00636
    00640     operator ULLONG () const;
    00641
    00643     operator float () const;
    00645     operator double () const;
    00647     operator bool () const;
    00649     operator CString () const;
    00651     operator CRef () const;
    00656     operator CRefArray () const;
    00658     operator unsigned char () const;
    00660     operator signed char () const;
    00662     operator CValueArray& () const;
    00663
    00667     operator CLongArray& () const;
    00668
    00672     operator CFloatArray& () const;
    00673
    00677     operator MATH::CVector3 () const;
    00678
    00682     operator MATH::CVector2f() const;
    00683
    00687     operator MATH::CVector3f() const;
    00688
    00692     operator MATH::CVector4f() const;
    00693
    00697     operator MATH::CMatrix3f() const;
    00698
    00702     operator MATH::CMatrix4f() const;
    00703
    00707     operator MATH::CRotationf() const;
    00708
    00712     operator MATH::CQuaternionf() const;
    00713
    00717     operator MATH::CColor4f() const;
    00718
    00722     operator MATH::CShape() const;
    00723
    00747     operator siPtrType () const;
    00748
    00752     bool operator==(const CValue& valSrc) const;
    00753
    00755     inline bool operator== (short) const;
    00757     inline bool operator== (unsigned short) const;
    00759     inline bool operator== (LONG) const;
    00760 #if !defined(linux) || !defined(__x86_64)
    00761
    00762     inline bool operator== (int) const;
    00763 #endif
    00764
    00765     inline bool operator== (ULONG) const;
    00766
    00770     inline bool operator== (LLONG) const;
    00771
    00775     inline bool operator== (ULLONG) const;
    00776
    00778     inline bool operator== (float) const;
    00780     inline bool operator== (double) const;
    00782     inline bool operator== (bool) const;
    00784     inline bool operator== (const CString&) const;
    00786     inline bool operator== (const wchar_t*) const;
    00788     inline bool operator== (const CRef&) const;
    00792     inline bool operator== (const CRefArray&) const;
    00794     inline bool operator== (unsigned char) const;
    00796     inline bool operator== (signed char) const;
    00798     bool operator== (const CValueArray&) const;
    00799
    00803     bool operator== (const CLongArray&) const;
    00804
    00808     bool operator== (const CFloatArray&) const;
    00809
    00811     inline bool operator== (const siPtrType) const;
    00812
    00816     inline bool operator== (const MATH::CVector3&) const;
    00817
    00821     inline bool operator== (const MATH::CVector2f&) const;
    00822
    00826     inline bool operator== (const MATH::CVector3f&) const;
    00827
    00831     inline bool operator== (const MATH::CVector4f&) const;
    00832
    00836     inline bool operator== (const MATH::CMatrix3f&) const;
    00837
    00841     inline bool operator== (const MATH::CMatrix4f&) const;
    00842
    00846     inline bool operator== (const MATH::CRotationf&) const;
    00847
    00851     inline bool operator== (const MATH::CQuaternionf&) const;
    00852
    00856     inline bool operator== (const MATH::CColor4f&) const;
    00857
    00861     inline bool operator== (const MATH::CShape&) const;
    00862
    00866     bool operator!=(const CValue& valSrc) const;
    00867
    00868     // low-level operations
    00869
    00913     void ChangeType( CValue::DataType in_type, const CValue* in_pSrc = NULL );
    00914
    00916     void Clear();
    00917
    00922     void Attach( CValue& in_valSrc);
    00923
    00928     CValue Detach();
    00929
    00933     CString GetAsText() const;
    00934
    00938     inline bool IsEmpty() const;
    00939 };
    00940
    00941 inline bool CValue::operator== (short val) const
    00942 {
    00943     return *this == CValue(val);
    00944 }
    00945
    00946 inline bool CValue::operator== (unsigned short val) const
    00947 {
    00948     return *this == CValue(val);
    00949 }
    00950
    00951 inline bool CValue::operator== (LONG val) const
    00952 {
    00953     return *this == CValue(val);
    00954 }
    00955
    00956 #if !defined(linux) || !defined(__x86_64)
    00957 inline bool CValue::operator== (int val) const
    00958 {
    00959     return *this == CValue(val);
    00960 }
    00961 #endif
    00962
    00963 inline bool CValue::operator== (ULONG val) const
    00964 {
    00965     return *this == CValue(val);
    00966 }
    00967
    00968 inline bool CValue::operator== (LLONG val) const
    00969 {
    00970     return *this == CValue(val);
    00971 }
    00972
    00973 inline bool CValue::operator== (ULLONG val) const
    00974 {
    00975     return *this == CValue(val);
    00976 }
    00977
    00978 inline bool CValue::operator== (float val) const
    00979 {
    00980     return *this == CValue(val);
    00981 }
    00982
    00983 inline bool CValue::operator== (double val) const
    00984 {
    00985     return *this == CValue(val);
    00986 }
    00987
    00988 inline bool CValue::operator== (bool val) const
    00989 {
    00990     return *this == CValue(val);
    00991 }
    00992
    00993 inline bool CValue::operator== (const CString& val) const
    00994 {
    00995     return *this == CValue(val);
    00996 }
    00997
    00998 inline bool CValue::operator== (const wchar_t* val) const
    00999 {
    01000     return *this == CValue(val);
    01001 }
    01002
    01003 inline bool CValue::operator== (const CRef& val) const
    01004 {
    01005     return *this == CValue(val);
    01006 }
    01007
    01008 inline bool CValue::operator== (const CRefArray& val) const
    01009 {
    01010     return *this == CValue(val);
    01011 }
    01012
    01013 inline bool CValue::operator== (unsigned char val) const
    01014 {
    01015     return *this == CValue(val);
    01016 }
    01017
    01018 inline bool CValue::operator== (signed char val) const
    01019 {
    01020     return *this == CValue(val);
    01021 }
    01022
    01023 inline bool CValue::operator== (const siPtrType val) const
    01024 {
    01025     return *this == CValue(val);
    01026 }
    01027
    01028 inline bool CValue::operator== (const MATH::CVector3& val) const
    01029 {
    01030     return *this == CValue(val);
    01031 }
    01032
    01033 inline bool CValue::operator== (const MATH::CVector2f& val) const
    01034 {
    01035     return *this == CValue(val);
    01036 }
    01037 inline bool CValue::operator== (const MATH::CVector3f& val) const
    01038 {
    01039     return *this == CValue(val);
    01040 }
    01041 inline bool CValue::operator== (const MATH::CVector4f& val) const
    01042 {
    01043     return *this == CValue(val);
    01044 }
    01045 inline bool CValue::operator== (const MATH::CQuaternionf& val) const
    01046 {
    01047     return *this == CValue(val);
    01048 }
    01049 inline bool CValue::operator== (const MATH::CRotationf& val) const
    01050 {
    01051     return *this == CValue(val);
    01052 }
    01053 inline bool CValue::operator== (const MATH::CMatrix3f& val) const
    01054 {
    01055     return *this == CValue(val);
    01056 }
    01057 inline bool CValue::operator== (const MATH::CMatrix4f& val) const
    01058 {
    01059     return *this == CValue(val);
    01060 }
    01061 inline bool CValue::operator== (const MATH::CColor4f& val) const
    01062 {
    01063     return *this == CValue(val);
    01064 }
    01065
    01066 inline bool CValue::operator== (const MATH::CShape& val) const
    01067 {
    01068     return *this == CValue(val);
    01069 }
    01070
    01071 inline bool CValue::IsEmpty() const
    01072 {
    01073     return m_t == siEmpty;
    01074 }
    01075
    01076 //*************************************************************************
    01085 //*************************************************************************
    01086 class SICPPSDKDECL CValueArray
    01087 {
    01088 public:
    01092     CValueArray(LONG in_size=0);
    01093
    01097     CValueArray(const CValueArray& in_array);
    01098
    01100     ~CValueArray();
    01101
    01106     CValueArray& operator=( const CValueArray& in_array );
    01107
    01111     LONG GetCount() const;
    01112
    01117     CStatus Add( const CValue& in_item );
    01118
    01122     CStatus Clear();
    01123
    01130     CStatus Resize( LONG in_size);
    01131
    01138     const CValue& operator[]( LONG in_index ) const;
    01139
    01145     CValue& operator[]( LONG in_index );
    01146
    01152     bool operator==(const CValueArray& in_array) const;
    01153
    01159     bool operator!=(const CValueArray& in_array) const;
    01160
    01161
    01162 private:
    01163
    01164     void* m_ptr;
    01165 };
    01166
    01167
    01168 };
    01169
    01170 #endif // __XSIVALUE_H__