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 
00164     struct Blob
00165     {
00166         ULONG m_nSize;
00167         unsigned char* m_pBlobData;
00168     };
00169     typedef Blob siBlobType;
00170 
00172     enum DataType
00173     {
00174         siEmpty = 0,    
00175         siInt2 = 2,     
00176         siInt4 = 3,     
00177         siInt8 = 10,    
00178         siFloat = 4,    
00179         siDouble = 5,   
00180         siString = 8,   
00181         siIDispatch = 9, 
00186         siBool = 11,    
00187         siIUnknown = 13, 
00190         siInt1 = 16,    
00191         siUInt1 = 17,   
00192         siUInt2 = 18,   
00193         siUInt4 = 19,   
00194         siUInt8 = 20,   
00195         siWStr  = 31,   
00197         siRef = 666,    
00198         siArray,        
00199         siPtr,          
00200         siRefArray,     
00201         siVector3,      
00202         siLongArray,    
00203         siFloatArray,   
00204         siVector2f=800, 
00205         siVector3f,     
00206         siVector4f,     
00207         siQuaternionf,  
00208         siRotationf,    
00209         siMatrix3f,     
00210         siMatrix4f,     
00211         siColor4f,      
00212         siShape,        
00213         siBlob,         
00214         siStringArray   
00215     };
00216 
00244     union ValueField
00245     {
00246         short               sval;       
00247         LONG                lval;       
00248         float               fval;       
00249         double              dval;       
00250         bool                bval;       
00251         wchar_t*            pwval;      
00252         siPtrType           pval;       
00253         signed char         cval;       
00254         unsigned char       ucval;      
00255         CValueArray*        paval;      
00256         CLongArray*         plaval;     
00257         CFloatArray*        pfaval;     
00258         unsigned short      usval;      
00259         ULONG               ulval;      
00260         MATH::CVector2f*    pv2f;       
00261         MATH::CVector3f*    pv3f;       
00262         MATH::CVector4f*    pv4f;       
00263         MATH::CQuaternionf* pqf;        
00264         MATH::CRotationf*   prf;        
00265         MATH::CMatrix3f*    pm3f;       
00266         MATH::CMatrix4f*    pm4f;       
00267         MATH::CColor4f*     pc4f;       
00268         MATH::CShape*       pshp;       
00269         LLONG               llval;      
00270         ULLONG              ullval;     
00271         siBlobType*         pblobval;   
00272         CStringArray*       pstrarrayval;       
00273     }m_u;
00274     DataType m_t;
00275 
00277     CValue();
00278 
00280     virtual ~CValue();
00281 
00285     CValue(const CValue& valSrc);
00286 
00290     CValue(short valSrc);
00291 
00295     CValue(unsigned short valSrc);
00296 
00300     CValue(LONG valSrc);
00301 
00302 #if !defined(linux) || !defined(__x86_64)
00303 
00306     CValue(int valSrc);
00307 #endif
00308 
00312     CValue(ULONG valSrc);
00313 
00318     CValue(LLONG valSrc);
00319 
00324     CValue(ULLONG valSrc);
00325 
00329     CValue(float valSrc);
00330 
00334     CValue(double valSrc);
00335 
00339     CValue(bool valSrc);
00340 
00344     CValue(const CString& valSrc);
00345 
00349     CValue(const CRef& valSrc);
00350 
00355     CValue(const CRefArray& valSrc);
00356 
00360     CValue(unsigned char valSrc);
00361 
00365     CValue(signed char valSrc);
00366 
00370     CValue(const CValueArray& valSrc);
00371 
00376     CValue(const CLongArray& valSrc);
00377 
00382     CValue(const CFloatArray& valSrc);
00383 
00388     CValue(const MATH::CVector3& valSrc);
00389 
00394     CValue(const MATH::CVector2f& valSrc);
00395 
00400     CValue(const MATH::CVector3f& valSrc);
00401 
00406     CValue(const MATH::CVector4f& val);
00407 
00412     CValue(const MATH::CQuaternionf& val);
00413 
00418     CValue(const MATH::CRotationf& val);
00419 
00424     CValue(const MATH::CMatrix3f& val);
00425 
00430     CValue(const MATH::CMatrix4f& val);
00431 
00436     CValue(const MATH::CColor4f& val);
00437 
00442     CValue(const MATH::CShape& val);
00443 
00447     CValue(siPtrType valSrc);
00448 
00452     CValue(const siBlobType& valSrc);
00453 
00457     CValue(const wchar_t* valSrc);
00458 
00462     CValue(const char* valSrc);
00463 
00468     CValue(const CStringArray& valSrc);
00469 
00473     CValue& operator=(const CValue& valSrc);
00474 
00478     CValue& operator=(short valSrc);
00479 
00483     CValue& operator=(unsigned short valSrc);
00484 
00488     CValue& operator=(LONG valSrc);
00489 
00490 #if !defined(linux) || !defined(__x86_64)
00491 
00494     CValue& operator=(int valSrc);
00495 #endif
00496 
00500     CValue& operator=(ULONG valSrc);
00501 
00506     CValue& operator=(LLONG valSrc);
00507 
00512     CValue& operator=(ULLONG valSrc);
00513 
00517     CValue& operator=(float valSrc);
00518 
00522     CValue& operator=(double valSrc);
00523 
00527     CValue& operator=(bool valSrc);
00528 
00532     CValue& operator=(const CString& valSrc);
00533 
00537     CValue& operator=(const wchar_t * valSrc );
00538 
00542     CValue& operator=(const char* valSrc );
00543 
00547     CValue& operator=(const CRef& valSrc);
00548 
00553     CValue& operator=(const CRefArray& valSrc);
00554 
00559     CValue& operator=(const MATH::CVector3& valSrc);
00560 
00565     CValue& operator=(const MATH::CVector2f& valSrc);
00566 
00571     CValue& operator=(const MATH::CVector3f& valSrc);
00572 
00577     CValue& operator=(const MATH::CVector4f& valSrc);
00578 
00583     CValue& operator=(const MATH::CMatrix3f& valSrc);
00584 
00589     CValue& operator=(const MATH::CMatrix4f& valSrc);
00590 
00595     CValue& operator=(const MATH::CRotationf& valSrc);
00596 
00601     CValue& operator=(const MATH::CQuaternionf& valSrc);
00602 
00607     CValue& operator=(const MATH::CColor4f& valSrc);
00608 
00613     CValue& operator=(const MATH::CShape& valSrc);
00614 
00618     CValue& operator=(unsigned char valSrc);
00619 
00623     CValue& operator=(signed char valSrc);
00624 
00628     CValue& operator=(const CValueArray& valSrc);
00629 
00633     CValue& operator=(const CLongArray& valSrc);
00634 
00638     CValue& operator=(const CFloatArray& valSrc);
00639 
00643     CValue& operator=(siPtrType valSrc);
00644 
00648     CValue& operator=(const siBlobType& valSrc );
00649 
00654     CValue& operator=(const CStringArray& valSrc );
00655 
00657     operator short () const;
00659     operator unsigned short () const;
00661     operator LONG () const;
00662 
00663 #if !defined(linux) || !defined(__x86_64)
00664 
00667     operator int () const;
00668 #endif
00669 
00673     operator ULONG () const;
00674 
00678     operator LLONG () const;
00679 
00683     operator ULLONG () const;
00684 
00686     operator float () const;
00688     operator double () const;
00690     operator bool () const;
00692     operator CString () const;
00694     operator CRef () const;
00699     operator CRefArray () const;
00701     operator unsigned char () const;
00703     operator signed char () const;
00705     operator CValueArray& () const;
00706 
00710     operator CLongArray& () const;
00711 
00715     operator CFloatArray& () const;
00716 
00720     operator MATH::CVector3 () const;
00721 
00725     operator MATH::CVector2f() const;
00726 
00730     operator MATH::CVector3f() const;
00731 
00735     operator MATH::CVector4f() const;
00736 
00740     operator MATH::CMatrix3f() const;
00741 
00745     operator MATH::CMatrix4f() const;
00746 
00750     operator MATH::CRotationf() const;
00751 
00755     operator MATH::CQuaternionf() const;
00756 
00760     operator MATH::CColor4f() const;
00761 
00765     operator MATH::CShape() const;
00766 
00790     operator siPtrType () const;
00791 
00795     operator siBlobType&() const;
00796 
00800     operator CStringArray&() const;
00801 
00805     bool operator==(const CValue& valSrc) const;
00806 
00808     inline bool operator== (short) const;
00810     inline bool operator== (unsigned short) const;
00812     inline bool operator== (LONG) const;
00813 #if !defined(linux) || !defined(__x86_64)
00814 
00815     inline bool operator== (int) const;
00816 #endif
00817 
00818     inline bool operator== (ULONG) const;
00819 
00823     inline bool operator== (LLONG) const;
00824 
00828     inline bool operator== (ULLONG) const;
00829 
00831     inline bool operator== (float) const;
00833     inline bool operator== (double) const;
00835     inline bool operator== (bool) const;
00837     inline bool operator== (const CString&) const;
00839     inline bool operator== (const wchar_t*) const;
00841     inline bool operator== (const char*) const;
00843     inline bool operator== (const CRef&) const;
00847     inline bool operator== (const CRefArray&) const;
00849     inline bool operator== (unsigned char) const;
00851     inline bool operator== (signed char) const;
00853     bool operator== (const CValueArray&) const;
00854 
00858     bool operator== (const CLongArray&) const;
00859 
00863     bool operator== (const CFloatArray&) const;
00864 
00866     inline bool operator== (const siPtrType) const;
00867 
00869     inline bool operator == (const siBlobType&) const;
00870 
00874     inline bool operator== (const MATH::CVector3&) const;
00875 
00879     inline bool operator== (const MATH::CVector2f&) const;
00880 
00884     inline bool operator== (const MATH::CVector3f&) const;
00885 
00889     inline bool operator== (const MATH::CVector4f&) const;
00890 
00894     inline bool operator== (const MATH::CMatrix3f&) const;
00895 
00899     inline bool operator== (const MATH::CMatrix4f&) const;
00900 
00904     inline bool operator== (const MATH::CRotationf&) const;
00905 
00909     inline bool operator== (const MATH::CQuaternionf&) const;
00910 
00914     inline bool operator== (const MATH::CColor4f&) const;
00915 
00919     inline bool operator== (const MATH::CShape&) const;
00920 
00924     inline bool operator== (const CStringArray&) const;
00925 
00929     bool operator!=(const CValue& valSrc) const;
00930 
00948     bool operator > (const CValue& val ) const;
00949 
00967     bool operator < (const CValue& val ) const;
00968 
00973     bool operator >= (const CValue& val ) const;
00974 
00979     bool operator <= (const CValue& val ) const;
00980 
00981     // low-level operations
00982 
01026     void ChangeType( CValue::DataType in_type, const CValue* in_pSrc = NULL );
01027 
01029     void Clear();
01030 
01035     void Attach( CValue& in_valSrc);
01036 
01041     CValue Detach();
01042 
01046     CString GetAsText() const;
01047 
01051     inline bool IsEmpty() const;
01052 };
01053 
01054 inline bool CValue::operator== (short val) const
01055 {
01056     return *this == CValue(val);
01057 }
01058 
01059 inline bool CValue::operator== (unsigned short val) const
01060 {
01061     return *this == CValue(val);
01062 }
01063 
01064 inline bool CValue::operator== (LONG val) const
01065 {
01066     return *this == CValue(val);
01067 }
01068 
01069 #if !defined(linux) || !defined(__x86_64)
01070 inline bool CValue::operator== (int val) const
01071 {
01072     return *this == CValue(val);
01073 }
01074 #endif
01075 
01076 inline bool CValue::operator== (ULONG val) const
01077 {
01078     return *this == CValue(val);
01079 }
01080 
01081 inline bool CValue::operator== (LLONG val) const
01082 {
01083     return *this == CValue(val);
01084 }
01085 
01086 inline bool CValue::operator== (ULLONG val) const
01087 {
01088     return *this == CValue(val);
01089 }
01090 
01091 inline bool CValue::operator== (float val) const
01092 {
01093     return *this == CValue(val);
01094 }
01095 
01096 inline bool CValue::operator== (double val) const
01097 {
01098     return *this == CValue(val);
01099 }
01100 
01101 inline bool CValue::operator== (bool val) const
01102 {
01103     return *this == CValue(val);
01104 }
01105 
01106 inline bool CValue::operator== (const CString& val) const
01107 {
01108     return *this == CValue(val);
01109 }
01110 
01111 inline bool CValue::operator== (const wchar_t* val) const
01112 {
01113     return *this == CValue(val);
01114 }
01115 
01116 inline bool CValue::operator== (const char* val) const
01117 {
01118     return *this == CValue(val);
01119 }
01120 
01121 inline bool CValue::operator== (const CRef& val) const
01122 {
01123     return *this == CValue(val);
01124 }
01125 
01126 inline bool CValue::operator== (const CRefArray& val) const
01127 {
01128     return *this == CValue(val);
01129 }
01130 
01131 inline bool CValue::operator== (unsigned char val) const
01132 {
01133     return *this == CValue(val);
01134 }
01135 
01136 inline bool CValue::operator== (signed char val) const
01137 {
01138     return *this == CValue(val);
01139 }
01140 
01141 inline bool CValue::operator== (const siPtrType val) const
01142 {
01143     return *this == CValue(val);
01144 }
01145 
01146 inline bool CValue::operator== (const siBlobType& val) const
01147 {
01148     return *this == CValue(val);
01149 }
01150 
01151 inline bool CValue::operator== (const MATH::CVector3& val) const
01152 {
01153     return *this == CValue(val);
01154 }
01155 
01156 inline bool CValue::operator== (const MATH::CVector2f& val) const
01157 {
01158     return *this == CValue(val);
01159 }
01160 inline bool CValue::operator== (const MATH::CVector3f& val) const
01161 {
01162     return *this == CValue(val);
01163 }
01164 inline bool CValue::operator== (const MATH::CVector4f& val) const
01165 {
01166     return *this == CValue(val);
01167 }
01168 inline bool CValue::operator== (const MATH::CQuaternionf& val) const
01169 {
01170     return *this == CValue(val);
01171 }
01172 inline bool CValue::operator== (const MATH::CRotationf& val) const
01173 {
01174     return *this == CValue(val);
01175 }
01176 inline bool CValue::operator== (const MATH::CMatrix3f& val) const
01177 {
01178     return *this == CValue(val);
01179 }
01180 inline bool CValue::operator== (const MATH::CMatrix4f& val) const
01181 {
01182     return *this == CValue(val);
01183 }
01184 inline bool CValue::operator== (const MATH::CColor4f& val) const
01185 {
01186     return *this == CValue(val);
01187 }
01188 
01189 inline bool CValue::operator== (const MATH::CShape& val) const
01190 {
01191     return *this == CValue(val);
01192 }
01193 
01194 inline bool CValue::operator== (const CStringArray& val) const
01195 {
01196     return *this == CValue(val);
01197 }
01198 
01199 inline bool CValue::IsEmpty() const
01200 {
01201     return m_t == siEmpty;
01202 }
01203 
01204 //*************************************************************************
01213 //*************************************************************************
01214 class SICPPSDKDECL CValueArray
01215 {
01216 public:
01220     CValueArray(LONG in_size=0);
01221 
01225     CValueArray(const CValueArray& in_array);
01226 
01228     ~CValueArray();
01229 
01234     CValueArray& operator=( const CValueArray& in_array );
01235 
01239     LONG GetCount() const;
01240 
01245     CStatus Add( const CValue& in_item );
01246 
01250     CStatus Clear();
01251 
01258     CStatus Resize( LONG in_size);
01259 
01266     const CValue& operator[]( LONG in_index ) const;
01267 
01273     CValue& operator[]( LONG in_index );
01274 
01280     bool operator==(const CValueArray& in_array) const;
01281 
01287     bool operator!=(const CValueArray& in_array) const;
01288 
01289 
01290 private:
01291 
01292     void* m_ptr;
01293 };
01294 
01295 
01296 };
01297 
01298 #endif // __XSIVALUE_H__