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     };
00215 
00243     union ValueField
00244     {
00245         short               sval;       
00246         LONG                lval;       
00247         float               fval;       
00248         double              dval;       
00249         bool                bval;       
00250         wchar_t*            pwval;      
00251         siPtrType           pval;       
00252         signed char         cval;       
00253         unsigned char       ucval;      
00254         CValueArray*        paval;      
00255         CLongArray*         plaval;     
00256         CFloatArray*        pfaval;     
00257         unsigned short      usval;      
00258         ULONG               ulval;      
00259         MATH::CVector2f*    pv2f;       
00260         MATH::CVector3f*    pv3f;       
00261         MATH::CVector4f*    pv4f;       
00262         MATH::CQuaternionf* pqf;        
00263         MATH::CRotationf*   prf;        
00264         MATH::CMatrix3f*    pm3f;       
00265         MATH::CMatrix4f*    pm4f;       
00266         MATH::CColor4f*     pc4f;       
00267         MATH::CShape*       pshp;       
00268         LLONG               llval;      
00269         ULLONG              ullval;     
00270         siBlobType*         pblobval;   
00271     }m_u;
00272     DataType m_t;
00273 
00275     CValue();
00276 
00278     virtual ~CValue();
00279 
00283     CValue(const CValue& valSrc);
00284 
00288     CValue(short valSrc);
00289 
00293     CValue(unsigned short valSrc);
00294 
00298     CValue(LONG valSrc);
00299 
00300 #if !defined(linux) || !defined(__x86_64)
00301 
00304     CValue(int valSrc);
00305 #endif
00306 
00310     CValue(ULONG valSrc);
00311 
00316     CValue(LLONG valSrc);
00317 
00322     CValue(ULLONG valSrc);
00323 
00327     CValue(float valSrc);
00328 
00332     CValue(double valSrc);
00333 
00337     CValue(bool valSrc);
00338 
00342     CValue(const CString& valSrc);
00343 
00347     CValue(const CRef& valSrc);
00348 
00353     CValue(const CRefArray& valSrc);
00354 
00358     CValue(unsigned char valSrc);
00359 
00363     CValue(signed char valSrc);
00364 
00368     CValue(const CValueArray& valSrc);
00369 
00374     CValue(const CLongArray& valSrc);
00375 
00380     CValue(const CFloatArray& valSrc);
00381 
00386     CValue(const MATH::CVector3& valSrc);
00387 
00392     CValue(const MATH::CVector2f& valSrc);
00393 
00398     CValue(const MATH::CVector3f& valSrc);
00399 
00404     CValue(const MATH::CVector4f& val);
00405 
00410     CValue(const MATH::CQuaternionf& val);
00411 
00416     CValue(const MATH::CRotationf& val);
00417 
00422     CValue(const MATH::CMatrix3f& val);
00423 
00428     CValue(const MATH::CMatrix4f& val);
00429 
00434     CValue(const MATH::CColor4f& val);
00435 
00440     CValue(const MATH::CShape& val);
00441 
00445     CValue(siPtrType valSrc);
00446 
00450     CValue(const siBlobType& valSrc);
00451 
00455     CValue(const wchar_t* valSrc);
00456 
00460     CValue& operator=(const CValue& valSrc);
00461 
00465     CValue& operator=(short valSrc);
00466 
00470     CValue& operator=(unsigned short valSrc);
00471 
00475     CValue& operator=(LONG valSrc);
00476 
00477 #if !defined(linux) || !defined(__x86_64)
00478 
00481     CValue& operator=(int valSrc);
00482 #endif
00483 
00487     CValue& operator=(ULONG valSrc);
00488 
00493     CValue& operator=(LLONG valSrc);
00494 
00499     CValue& operator=(ULLONG valSrc);
00500 
00504     CValue& operator=(float valSrc);
00505 
00509     CValue& operator=(double valSrc);
00510 
00514     CValue& operator=(bool valSrc);
00515 
00519     CValue& operator=(const CString& valSrc);
00520 
00524     CValue& operator=(const wchar_t * valSrc );
00525 
00529     CValue& operator=(const CRef& valSrc);
00530 
00535     CValue& operator=(const CRefArray& valSrc);
00536 
00541     CValue& operator=(const MATH::CVector3& valSrc);
00542 
00547     CValue& operator=(const MATH::CVector2f& valSrc);
00548 
00553     CValue& operator=(const MATH::CVector3f& valSrc);
00554 
00559     CValue& operator=(const MATH::CVector4f& valSrc);
00560 
00565     CValue& operator=(const MATH::CMatrix3f& valSrc);
00566 
00571     CValue& operator=(const MATH::CMatrix4f& valSrc);
00572 
00577     CValue& operator=(const MATH::CRotationf& valSrc);
00578 
00583     CValue& operator=(const MATH::CQuaternionf& valSrc);
00584 
00589     CValue& operator=(const MATH::CColor4f& valSrc);
00590 
00595     CValue& operator=(const MATH::CShape& valSrc);
00596 
00600     CValue& operator=(unsigned char valSrc);
00601 
00605     CValue& operator=(signed char valSrc);
00606 
00610     CValue& operator=(const CValueArray& valSrc);
00611 
00615     CValue& operator=(const CLongArray& valSrc);
00616 
00620     CValue& operator=(const CFloatArray& valSrc);
00621 
00625     CValue& operator=(siPtrType valSrc);
00626 
00630     CValue& operator=(const siBlobType& valSrc );
00631 
00633     operator short () const;
00635     operator unsigned short () const;
00637     operator LONG () const;
00638 
00639 #if !defined(linux) || !defined(__x86_64)
00640 
00643     operator int () const;
00644 #endif
00645 
00649     operator ULONG () const;
00650 
00654     operator LLONG () const;
00655 
00659     operator ULLONG () const;
00660 
00662     operator float () const;
00664     operator double () const;
00666     operator bool () const;
00668     operator CString () const;
00670     operator CRef () const;
00675     operator CRefArray () const;
00677     operator unsigned char () const;
00679     operator signed char () const;
00681     operator CValueArray& () const;
00682 
00686     operator CLongArray& () const;
00687 
00691     operator CFloatArray& () const;
00692 
00696     operator MATH::CVector3 () const;
00697 
00701     operator MATH::CVector2f() const;
00702 
00706     operator MATH::CVector3f() const;
00707 
00711     operator MATH::CVector4f() const;
00712 
00716     operator MATH::CMatrix3f() const;
00717 
00721     operator MATH::CMatrix4f() const;
00722 
00726     operator MATH::CRotationf() const;
00727 
00731     operator MATH::CQuaternionf() const;
00732 
00736     operator MATH::CColor4f() const;
00737 
00741     operator MATH::CShape() const;
00742 
00766     operator siPtrType () const;
00767 
00771     operator siBlobType&() const;
00772 
00776     bool operator==(const CValue& valSrc) const;
00777 
00779     inline bool operator== (short) const;
00781     inline bool operator== (unsigned short) const;
00783     inline bool operator== (LONG) const;
00784 #if !defined(linux) || !defined(__x86_64)
00785 
00786     inline bool operator== (int) const;
00787 #endif
00788 
00789     inline bool operator== (ULONG) const;
00790 
00794     inline bool operator== (LLONG) const;
00795 
00799     inline bool operator== (ULLONG) const;
00800 
00802     inline bool operator== (float) const;
00804     inline bool operator== (double) const;
00806     inline bool operator== (bool) const;
00808     inline bool operator== (const CString&) const;
00810     inline bool operator== (const wchar_t*) const;
00812     inline bool operator== (const CRef&) const;
00816     inline bool operator== (const CRefArray&) const;
00818     inline bool operator== (unsigned char) const;
00820     inline bool operator== (signed char) const;
00822     bool operator== (const CValueArray&) const;
00823 
00827     bool operator== (const CLongArray&) const;
00828 
00832     bool operator== (const CFloatArray&) const;
00833 
00835     inline bool operator== (const siPtrType) const;
00836 
00838     inline bool operator == (const siBlobType&) const;
00839 
00843     inline bool operator== (const MATH::CVector3&) const;
00844 
00848     inline bool operator== (const MATH::CVector2f&) const;
00849 
00853     inline bool operator== (const MATH::CVector3f&) const;
00854 
00858     inline bool operator== (const MATH::CVector4f&) const;
00859 
00863     inline bool operator== (const MATH::CMatrix3f&) const;
00864 
00868     inline bool operator== (const MATH::CMatrix4f&) const;
00869 
00873     inline bool operator== (const MATH::CRotationf&) const;
00874 
00878     inline bool operator== (const MATH::CQuaternionf&) const;
00879 
00883     inline bool operator== (const MATH::CColor4f&) const;
00884 
00888     inline bool operator== (const MATH::CShape&) const;
00889 
00893     bool operator!=(const CValue& valSrc) const;
00894 
00895     // low-level operations
00896 
00940     void ChangeType( CValue::DataType in_type, const CValue* in_pSrc = NULL );
00941 
00943     void Clear();
00944 
00949     void Attach( CValue& in_valSrc);
00950 
00955     CValue Detach();
00956 
00960     CString GetAsText() const;
00961 
00965     inline bool IsEmpty() const;
00966 };
00967 
00968 inline bool CValue::operator== (short val) const
00969 {
00970     return *this == CValue(val);
00971 }
00972 
00973 inline bool CValue::operator== (unsigned short val) const
00974 {
00975     return *this == CValue(val);
00976 }
00977 
00978 inline bool CValue::operator== (LONG val) const
00979 {
00980     return *this == CValue(val);
00981 }
00982 
00983 #if !defined(linux) || !defined(__x86_64)
00984 inline bool CValue::operator== (int val) const
00985 {
00986     return *this == CValue(val);
00987 }
00988 #endif
00989 
00990 inline bool CValue::operator== (ULONG val) const
00991 {
00992     return *this == CValue(val);
00993 }
00994 
00995 inline bool CValue::operator== (LLONG val) const
00996 {
00997     return *this == CValue(val);
00998 }
00999 
01000 inline bool CValue::operator== (ULLONG val) const
01001 {
01002     return *this == CValue(val);
01003 }
01004 
01005 inline bool CValue::operator== (float val) const
01006 {
01007     return *this == CValue(val);
01008 }
01009 
01010 inline bool CValue::operator== (double val) const
01011 {
01012     return *this == CValue(val);
01013 }
01014 
01015 inline bool CValue::operator== (bool val) const
01016 {
01017     return *this == CValue(val);
01018 }
01019 
01020 inline bool CValue::operator== (const CString& val) const
01021 {
01022     return *this == CValue(val);
01023 }
01024 
01025 inline bool CValue::operator== (const wchar_t* val) const
01026 {
01027     return *this == CValue(val);
01028 }
01029 
01030 inline bool CValue::operator== (const CRef& val) const
01031 {
01032     return *this == CValue(val);
01033 }
01034 
01035 inline bool CValue::operator== (const CRefArray& val) const
01036 {
01037     return *this == CValue(val);
01038 }
01039 
01040 inline bool CValue::operator== (unsigned char val) const
01041 {
01042     return *this == CValue(val);
01043 }
01044 
01045 inline bool CValue::operator== (signed char val) const
01046 {
01047     return *this == CValue(val);
01048 }
01049 
01050 inline bool CValue::operator== (const siPtrType val) const
01051 {
01052     return *this == CValue(val);
01053 }
01054 
01055 inline bool CValue::operator== (const siBlobType& val) const
01056 {
01057     return *this == CValue(val);
01058 }
01059 
01060 inline bool CValue::operator== (const MATH::CVector3& val) const
01061 {
01062     return *this == CValue(val);
01063 }
01064 
01065 inline bool CValue::operator== (const MATH::CVector2f& val) const
01066 {
01067     return *this == CValue(val);
01068 }
01069 inline bool CValue::operator== (const MATH::CVector3f& val) const
01070 {
01071     return *this == CValue(val);
01072 }
01073 inline bool CValue::operator== (const MATH::CVector4f& val) const
01074 {
01075     return *this == CValue(val);
01076 }
01077 inline bool CValue::operator== (const MATH::CQuaternionf& val) const
01078 {
01079     return *this == CValue(val);
01080 }
01081 inline bool CValue::operator== (const MATH::CRotationf& val) const
01082 {
01083     return *this == CValue(val);
01084 }
01085 inline bool CValue::operator== (const MATH::CMatrix3f& val) const
01086 {
01087     return *this == CValue(val);
01088 }
01089 inline bool CValue::operator== (const MATH::CMatrix4f& val) const
01090 {
01091     return *this == CValue(val);
01092 }
01093 inline bool CValue::operator== (const MATH::CColor4f& val) const
01094 {
01095     return *this == CValue(val);
01096 }
01097 
01098 inline bool CValue::operator== (const MATH::CShape& val) const
01099 {
01100     return *this == CValue(val);
01101 }
01102 
01103 inline bool CValue::IsEmpty() const
01104 {
01105     return m_t == siEmpty;
01106 }
01107 
01108 //*************************************************************************
01117 //*************************************************************************
01118 class SICPPSDKDECL CValueArray
01119 {
01120 public:
01124     CValueArray(LONG in_size=0);
01125 
01129     CValueArray(const CValueArray& in_array);
01130 
01132     ~CValueArray();
01133 
01138     CValueArray& operator=( const CValueArray& in_array );
01139 
01143     LONG GetCount() const;
01144 
01149     CStatus Add( const CValue& in_item );
01150 
01154     CStatus Clear();
01155 
01162     CStatus Resize( LONG in_size);
01163 
01170     const CValue& operator[]( LONG in_index ) const;
01171 
01177     CValue& operator[]( LONG in_index );
01178 
01184     bool operator==(const CValueArray& in_array) const;
01185 
01191     bool operator!=(const CValueArray& in_array) const;
01192 
01193 
01194 private:
01195 
01196     void* m_ptr;
01197 };
01198 
01199 
01200 };
01201 
01202 #endif // __XSIVALUE_H__