Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

xmog_java_field.h

00001 /*
00002  * Copyright 1999-2006 by Codemesh, Inc.  ALL RIGHTS RESERVED.
00003  */
00004 
00005 #ifndef xmog_java_field_inc
00006 #define xmog_java_field_inc
00007 
00008 
00009 class xmog_java_class;
00010 
00011 
00012 #include "xmog_java_dynamic.h"
00013 #include "xmog_java_string.h"
00014 
00015 
00035 class XMOG_DECLSPEC xmog_java_field : public xmog_java_dynamic
00036 {
00037 private:
00038 
00045     jfieldID        fid_;
00046 
00050     xmog_java_class * clazz_;
00051 
00057     xmog_java_field * next_;
00058 
00062     char *          name_;
00063 
00067     char *          type_;
00068 
00072     bool            bStatic_;
00073 
00074 public:
00075 
00076     friend class xmog_java_class;
00077 
00088     xmog_java_field( xmog_java_class * clazz, jfieldID fid, bool bStatic = false );
00089 
00100     xmog_java_field( xmog_java_class * clazz, const char * name, const char * type, bool bStatic = false );
00101 
00105     ~xmog_java_field();
00106 
00111     void *          operator new ( size_t );
00112 
00117     void            operator delete( void * );
00118 
00122     xmog_java_field *   next();
00123 
00127     xmog_java_class *   clazz();
00128 
00132     const char *        name();
00133 
00137     const char *        type();
00138 
00142     bool            is_static() const;
00143 
00150     void            set_fieldID( jfieldID fid );
00151 
00155     jfieldID        get_fieldID();
00156 
00163     int             initializeFieldID( xmog_localenv * env );
00164 
00173     virtual bool    get_bool( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00174 
00183     virtual jboolean get_jboolean( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00184 
00193     virtual jbyte   get_byte( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00194 
00203     virtual jchar   get_char( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00204 
00213     virtual jdouble get_double( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00214 
00223     virtual jfloat  get_float( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00224 
00233     virtual jint    get_int( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00234 
00243     virtual jlong   get_long( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00244 
00253     virtual jshort  get_short( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00254 
00263     virtual jobject get_jobject( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = xmog_base::GLOBAL ) ;
00264 
00275     virtual void    get_void( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00276 
00284     virtual void    set_bool( xmog_base * obj, bool b, xmog_localenv * env = NULL ) ;
00285 
00293     virtual void    set_jboolean( xmog_base * obj, jboolean b, xmog_localenv * env = NULL ) ;
00294 
00302     virtual void    set_byte( xmog_base * obj, jbyte b, xmog_localenv * env = NULL ) ;
00303 
00311     virtual void    set_char( xmog_base * obj, jchar ch, xmog_localenv * env = NULL ) ;
00312 
00320     virtual void    set_double( xmog_base * obj, jdouble d, xmog_localenv * env = NULL ) ;
00321 
00329     virtual void    set_float( xmog_base * obj, jfloat f, xmog_localenv * env = NULL ) ;
00330 
00338     virtual void    set_int( xmog_base * obj, jint i, xmog_localenv * env = NULL ) ;
00339 
00347     virtual void    set_long( xmog_base * obj, jlong l, xmog_localenv * env = NULL ) ;
00348 
00356     virtual void    set_short( xmog_base * obj, jshort sh, xmog_localenv * env = NULL ) ;
00357 
00365     virtual void    set_jobject( xmog_base * obj, jobject o, xmog_localenv * env = NULL ) ;
00366 };
00367 
00368 
00385 class XMOG_DECLSPEC xmog_bool : public xmog_base
00386 {
00387 private:
00388 
00395     bool        theValue_;
00396 
00397 public:
00398 
00405     xmog_bool( xmog_java_array * _ref, jint _index );
00406 
00414     xmog_bool( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
00415 
00424     operator bool() const;
00425 
00431     bool    operator * () const;
00432 
00441     xmog_bool & operator = ( bool );
00442 
00456     bool    get( xmog_localenv * env = NULL, bool readThrough = false ) const;
00457 
00471     void    set( bool b, xmog_localenv * env = NULL, bool writeThrough = false );
00472 };
00473 
00474 
00491 class XMOG_DECLSPEC xmog_jboolean : public xmog_base
00492 {
00493 private:
00494 
00501     jboolean        theValue_;
00502 
00503 public:
00504 
00511     xmog_jboolean( xmog_java_array * _ref, jint _index );
00512 
00520     xmog_jboolean( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
00521 
00530     operator jboolean() const;
00531 
00537     jboolean    operator * () const;
00538 
00547     xmog_jboolean & operator = ( jboolean );
00548 
00562     jboolean    get( xmog_localenv * env = NULL, bool readThrough = false ) const;
00563 
00577     void    set( jboolean b, xmog_localenv * env = NULL, bool writeThrough = false );
00578 };
00579 
00580 
00597 class XMOG_DECLSPEC xmog_byte : public xmog_base
00598 {
00599 private:
00600 
00607     jbyte       theValue_;
00608 
00609 public:
00610 
00617     xmog_byte( xmog_java_array * _ref, jint _index );
00618 
00626     xmog_byte( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
00627 
00636     operator jbyte() const;
00637 
00643     jbyte   operator * () const;
00644 
00653     xmog_byte & operator = ( jbyte );
00654 
00663     xmog_byte & operator |= ( jbyte );
00664 
00673     xmog_byte & operator &= ( jbyte );
00674 
00683     xmog_byte & operator ^= ( jbyte );
00684 
00693     xmog_byte & operator += ( jbyte );
00694 
00703     xmog_byte & operator -= ( jbyte );
00704 
00713     xmog_byte & operator *= ( int );
00714 
00723     xmog_byte & operator /= ( int );
00724 
00738     jbyte   get( xmog_localenv * env = NULL, bool readThrough = false ) const;
00739 
00753     void    set( jbyte b, xmog_localenv * env = NULL, bool writeThrough = false );
00754 };
00755 
00756 
00765 class XMOG_DECLSPEC xmog_char : public xmog_base
00766 {
00767 private:
00768 
00775     jchar       theValue_;
00776 
00777 public:
00778 
00785     xmog_char( xmog_java_array * _ref, jint _index );
00786 
00794     xmog_char( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
00795 
00807     operator int() const;
00808 
00814     int operator * () const;
00815 
00824     xmog_char & operator = ( int );
00825 
00834     xmog_char & operator |= ( int );
00835 
00844     xmog_char & operator &= ( int );
00845 
00854     xmog_char & operator ^= ( int );
00855 
00864     xmog_char & operator += ( int );
00865 
00874     xmog_char & operator -= ( int );
00875 
00884     xmog_char & operator *= ( int );
00885 
00894     xmog_char & operator /= ( int );
00895 
00909     int     get( xmog_localenv * env = NULL, bool readThrough = false ) const;
00910 
00924     void    set( int c, xmog_localenv * env = NULL, bool writeThrough = false );
00925 };
00926 
00927 
00936 class XMOG_DECLSPEC xmog_double : public xmog_base
00937 {
00938 private:
00939 
00946     jdouble     theValue_;
00947 
00948 public:
00949 
00956     xmog_double( xmog_java_array * _ref, jint _index );
00957 
00965     xmog_double( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
00966 
00975     operator jdouble() const;
00976 
00982     jdouble operator * () const;
00983 
00992     xmog_double &   operator = ( jdouble );
00993 
01002     xmog_double &   operator += ( jdouble );
01003 
01012     xmog_double &   operator -= ( jdouble );
01013 
01022     xmog_double &   operator *= ( jdouble );
01023 
01032     xmog_double &   operator /= ( jdouble );
01033 
01047     jdouble     get( xmog_localenv * env = NULL, bool readThrough = false ) const;
01048 
01062     void        set( jdouble d, xmog_localenv * env = NULL, bool writeThrough = false );
01063 };
01064 
01065 
01074 class XMOG_DECLSPEC xmog_float : public xmog_base
01075 {
01076 private:
01077 
01084     jfloat      theValue_;
01085 
01086 public:
01087 
01094     xmog_float( xmog_java_array * _ref, jint _index );
01095 
01103     xmog_float( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
01104 
01113     operator jfloat() const;
01114 
01120     jfloat  operator * () const;
01121 
01130     xmog_float &    operator = ( jfloat );
01131 
01140     xmog_float &    operator += ( jfloat );
01141 
01150     xmog_float &    operator -= ( jfloat );
01151 
01160     xmog_float &    operator *= ( jfloat );
01161 
01170     xmog_float &    operator /= ( jfloat );
01171 
01185     jfloat      get( xmog_localenv * env = NULL, bool readThrough = false ) const;
01186 
01200     void        set( jfloat f, xmog_localenv * env = NULL, bool writeThrough = false );
01201 };
01202 
01203 
01212 class XMOG_DECLSPEC xmog_int : public xmog_base
01213 {
01214 private:
01215 
01222     jint        theValue_;
01223 
01224 public:
01225 
01232     xmog_int( xmog_java_array * _ref, jint _index );
01233 
01241     xmog_int( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
01242 
01251     operator jint() const;
01252 
01258     jint    operator * () const;
01259 
01268     xmog_int &  operator = ( jint );
01269 
01278     xmog_int &  operator &= ( jint );
01279 
01288     xmog_int &  operator |= ( jint );
01289 
01298     xmog_int &  operator ^= ( jint );
01299 
01308     xmog_int &  operator %= ( jint );
01309 
01318     xmog_int &  operator >>= ( int );
01319 
01328     xmog_int &  operator <<= ( int );
01329 
01338     xmog_int &  operator += ( jint );
01339 
01348     xmog_int &  operator -= ( jint );
01349 
01358     xmog_int &  operator *= ( jint );
01359 
01368     xmog_int &  operator /= ( jint );
01369 
01383     jint        get( xmog_localenv * env = NULL, bool readThrough = false ) const;
01384 
01398     void        set( jint i, xmog_localenv * env = NULL, bool writeThrough = false );
01399 };
01400 
01401 
01410 class XMOG_DECLSPEC xmog_long : public xmog_base
01411 {
01412 private:
01413 
01420     jlong       theValue_;
01421 
01422 public:
01423 
01430     xmog_long( xmog_java_array * _ref, jint _index );
01431 
01439     xmog_long( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
01440 
01449     operator jlong() const;
01450 
01456     jlong   operator * () const;
01457 
01466     xmog_long & operator = ( jlong );
01467 
01476     xmog_long & operator &= ( jlong );
01477 
01486     xmog_long & operator |= ( jlong );
01487 
01496     xmog_long & operator ^= ( jlong );
01497 
01506     xmog_long & operator %= ( jlong );
01507 
01516     xmog_long & operator >>= ( int );
01517 
01526     xmog_long & operator <<= ( int );
01527 
01536     xmog_long & operator += ( jlong );
01537 
01546     xmog_long & operator -= ( jlong );
01547 
01556     xmog_long & operator *= ( jlong );
01557 
01566     xmog_long & operator /= ( jlong );
01567 
01581     jlong       get( xmog_localenv * env = NULL, bool readThrough = false ) const;
01582 
01596     void        set( jlong l, xmog_localenv * env = NULL, bool writeThrough = false );
01597 };
01598 
01599 
01608 class XMOG_DECLSPEC xmog_short : public xmog_base
01609 {
01610 private:
01611 
01618     jshort      theValue_;
01619 
01620 public:
01621 
01628     xmog_short( xmog_java_array * _ref, jint _index );
01629 
01637     xmog_short( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = 0 ); 
01638 
01647     operator jshort() const;
01648 
01654     jshort  operator * () const;
01655 
01664     xmog_short &    operator = ( jshort );
01665 
01674     xmog_short &    operator &= ( jshort );
01675 
01684     xmog_short &    operator |= ( jshort );
01685 
01694     xmog_short &    operator ^= ( jshort );
01695 
01704     xmog_short &    operator %= ( jshort );
01705 
01714     xmog_short &    operator >>= ( int );
01715 
01724     xmog_short &    operator <<= ( int );
01725 
01734     xmog_short &    operator += ( jshort );
01735 
01744     xmog_short &    operator -= ( jshort );
01745 
01754     xmog_short &    operator *= ( jshort );
01755 
01764     xmog_short &    operator /= ( jshort );
01765 
01779     jshort      get( xmog_localenv * env = NULL, bool readThrough = false ) const;
01780 
01794     void        set( jshort s, xmog_localenv * env = NULL, bool writeThrough = false );
01795 };
01796 
01797 
01807 template < class FieldType > class xmog_field_t : public xmog_java_ref
01808 {
01809 public:
01810     
01818     xmog_field_t( xmog_java_ref * _inst, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL ) :
01819         xmog_java_ref( _inst, _dynamic, _flags )
01820     {
01821     }
01822 
01828     FieldType   operator = ( const FieldType & _inst )
01829     {
01830         this->copy_jobject_( &_inst );
01831     }
01832 
01838     FieldType   operator = ( const xmog_null & _null_inst )
01839     {
01840         xmog_base   temp;
01841 
01842         this->set_jobject_( &temp );
01843     }
01844 
01848     operator FieldType() const
01849     {
01850         return FieldType( (xmog_java_ref*)XMOG_JOBJECT_VALUE(owner_), dynamic_, flags_ );
01851     }
01852 
01858     FieldType   operator * () const
01859     {
01860         return FieldType( (xmog_java_ref*)XMOG_JOBJECT_VALUE(owner_), dynamic_, flags_ );
01861     }
01862 
01866     operator FieldType()
01867     {
01868         return FieldType( (xmog_java_ref*)XMOG_JOBJECT_VALUE(owner_), dynamic_, flags_ );
01869     }
01870 
01871 };
01872 
01873 
01883 template < class FieldType > class xmog_string_field_t : public xmog_field_t< FieldType >
01884 {
01885 public:
01886     
01887     xmog_string_field_t( xmog_java_ref * _inst, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL ) :
01888         xmog_field_t< FieldType>( _inst, _dynamic, _flags )
01889     {
01890     }
01891 
01892     FieldType   operator = ( const char * _str )
01893     {
01894         xmog_java_string::from_char( (xmog_base*)this, xmog_base::GLOBAL, _str, -1, NULL );
01895         return this->operator FieldType();
01896     }
01897 
01898 #   if (XMOG_SUPPORTS_WCHAR_T==1)
01899     FieldType   operator = ( const XMOG_WCHAR * _wstr )
01900     {
01901         xmog_java_string::from_wchar( (xmog_base*)this, xmog_base::GLOBAL, _wstr, -1, NULL );
01902         return this->operator FieldType();
01903     }
01904 #   endif
01905 
01906 #   if (XMOG_REQUIRES_UNSIGNED_SHORT_OVERLOAD==1)
01907     FieldType   operator = ( const unsigned short * _wstr )
01908     {
01909         xmog_java_string::from_wchar( (xmog_base*)this, xmog_base::GLOBAL, (XMOG_WCHAR*)_wstr, -1, NULL );
01910         return this->operator FieldType();
01911     }
01912 #   endif
01913 
01914 };
01915 
01916 #endif /* xmog_java_field_inc */

Generated on Fri Jun 16 10:18:58 2006 for JMS Courier for C++ by  doxygen 1.4.1