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

xmog_java_array.h

00001 /*
00002  * Copyright 1999-2006 by Codemesh, Inc.  ALL RIGHTS RESERVED.
00003  */
00004 
00005 #ifndef xmog_java_array_inc
00006 #define xmog_java_array_inc
00007 
00008 
00009 #include "xmog.h"
00010 #include "xmog_base.h"
00011 #include "xmog_java_ref.h"
00012 #include "xmog_java_dynamic.h"
00013 
00014 
00015 
00017 
00018 class xmog_java_array;
00019 struct xmog_java_values;
00020 class xmog_localenv;
00021 class xmog_bool;
00022 class xmog_jboolean;
00023 class xmog_byte;
00024 class xmog_char;
00025 class xmog_double;
00026 class xmog_float;
00027 class xmog_int;
00028 class xmog_long;
00029 class xmog_short;
00030 class xmog_null;
00031 
00033 
00162 
00178 class XMOG_DECLSPEC xmog_java_element : public xmog_java_dynamic
00179 {
00180 public:
00181 
00185     static xmog_java_element    theElement;
00186 
00190     xmog_java_element();
00191 
00195     ~xmog_java_element();
00196 
00205     virtual bool    get_bool( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00206 
00215     virtual jboolean get_jboolean( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00216 
00225     virtual jbyte   get_byte( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00226 
00235     virtual jchar   get_char( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00236 
00245     virtual jdouble get_double( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00246 
00255     virtual jfloat  get_float( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00256 
00265     virtual jint    get_int( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00266 
00275     virtual jlong   get_long( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00276 
00285     virtual jshort  get_short( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00286 
00295     virtual jobject get_jobject( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = xmog_base::GLOBAL ) ;
00296 
00307     virtual void    get_void( xmog_base * obj, xmog_java_values * args = NULL, xmog_localenv * env = NULL, xmog_flags flags = 0 ) ;
00308 
00316     virtual void    set_bool( xmog_base * obj, bool b, xmog_localenv * env = NULL ) ;
00317 
00325     virtual void    set_jboolean( xmog_base * obj, jboolean b, xmog_localenv * env = NULL ) ;
00326 
00334     virtual void    set_byte( xmog_base * obj, jbyte b, xmog_localenv * env = NULL ) ;
00335 
00343     virtual void    set_char( xmog_base * obj, jchar ch, xmog_localenv * env = NULL ) ;
00344 
00352     virtual void    set_double( xmog_base * obj, jdouble d, xmog_localenv * env = NULL ) ;
00353 
00361     virtual void    set_float( xmog_base * obj, jfloat f, xmog_localenv * env = NULL ) ;
00362 
00370     virtual void    set_int( xmog_base * obj, jint i, xmog_localenv * env = NULL ) ;
00371 
00379     virtual void    set_long( xmog_base * obj, jlong l, xmog_localenv * env = NULL ) ;
00380 
00388     virtual void    set_short( xmog_base * obj, jshort sh, xmog_localenv * env = NULL ) ;
00389 
00397     virtual void    set_jobject( xmog_base * obj, jobject o, xmog_localenv * env = NULL ) ;
00398 };
00399 
00400 
00408 class XMOG_DECLSPEC xmog_java_array_size
00409 {
00410 private:
00411 
00412     xmog_java_array *   owner_;
00413 
00414     XMOG_MUTABLE jint   size_;
00415 
00416 public:
00417 
00418     friend class xmog_java_array;
00419 
00427     XMOG_EXPLICIT   xmog_java_array_size( xmog_java_array * owner, jint size = -1 );
00428 
00435     operator jint() const;
00436 
00445     jint        to_jint( xmog_localenv * env ) const;
00446 };
00447 
00448 
00454 class XMOG_DECLSPEC xmog_java_array : public xmog_java_ref
00455 {
00456 public:
00457 
00461     xmog_java_array();
00462 
00471     xmog_java_array( jobject array, xmog_flags flags, jint size = -1, xmog_localenv * env = NULL );
00472 
00479     xmog_java_array( const xmog_null & ); 
00480 
00487     xmog_java_array( const xmog_java_array & _rhs, xmog_localenv * env = NULL ); 
00488 
00499     xmog_java_array( xmog_java_array * _arr, jint _index );
00500 
00511     xmog_java_array( xmog_java_class * _clazz, xmog_java_dynamic * _dynamic, xmog_flags _flags );
00512 
00528     xmog_java_array( xmog_base * _delegate, bool _owns_delegate = true );
00529 
00540     xmog_java_array( xmog_java_ref * _ref, xmog_java_dynamic * _dynamic, xmog_flags _flags );
00541 
00545     ~xmog_java_array();
00546 
00553     xmog_java_array_size        length;
00554 
00560     jint                        get_length( xmog_localenv * env ) const;
00561 
00567     void                        xmog_invalidate( xmog_localenv * env = NULL );
00568 
00569 protected:
00570 
00574     void    copy_( const xmog_java_array & _rhs, xmog_localenv * env = NULL );
00575 
00576 private:
00577 
00581     void *                      ptr_;
00582 };
00583 
00584 
00592 template< class ArrayType >
00593 class xmog_array_iterator
00594 {
00595 private:
00596 
00598     ArrayType           array_;
00599 
00601     jint                index_;
00602 
00603 public:
00604 
00606     typedef typename ArrayType::difference_type difference_type;
00607 
00611     typedef typename ArrayType::value_type      value_type;
00612 
00614     xmog_array_iterator< ArrayType >() :
00615         array_(),
00616         index_( -1 )
00617     {
00618     }
00619 
00622     xmog_array_iterator< ArrayType >( const xmog_array_iterator< ArrayType > & rhs ) :
00623         array_( rhs.array_ ),
00624         index_( rhs.index_ )
00625     {
00626     }
00627 
00630     xmog_array_iterator< ArrayType >( ArrayType & arr ) :
00631         array_( arr ),
00632         index_( 0 )
00633     {
00634     }
00635 
00639     xmog_array_iterator< ArrayType >( ArrayType & arr, jint ind ) :
00640         array_( arr ),
00641         index_( ind )
00642     {
00643         if( index_ == -1 && !array_.is_null_() )
00644             index_ = array_.length;
00645     }
00646 
00648     ~xmog_array_iterator< ArrayType > ()
00649     {
00650     }
00651 
00654     xmog_array_iterator< ArrayType> &   operator = ( const xmog_array_iterator< ArrayType > & rhs )
00655     {
00656         array_ = rhs.array_;
00657         index_ = rhs.index_;
00658         return *this;
00659     }
00660 
00661     bool    operator < ( const xmog_array_iterator< ArrayType > & rhs ) const
00662     {
00663         return ( index_ != -1 && index_ < rhs.index_ ) || rhs.index_ == -1;
00664     }
00665 
00666     bool    operator <= ( const xmog_array_iterator< ArrayType > & rhs ) const
00667     {
00668         return rhs.index_ == -1 || ( index_ != -1 && index_ <= rhs.index_ );
00669     }
00670 
00671     bool    operator > ( const xmog_array_iterator< ArrayType > & rhs ) const
00672     {
00673         return ( rhs.index_ != -1 && rhs.index_ < index_ ) || index_ == -1;
00674     }
00675 
00676     bool    operator >= ( const xmog_array_iterator< ArrayType > & rhs ) const
00677     {
00678         return index_ == -1 || ( rhs.index_ != -1 && rhs.index_ < index_ );
00679     }
00680 
00681     bool    operator == ( const xmog_array_iterator< ArrayType > & rhs ) const
00682     {
00683         return ( index_ == rhs.index_ );
00684     }
00685 
00686     bool    operator != ( const xmog_array_iterator< ArrayType > & rhs ) const
00687     {
00688         return ( index_ != rhs.index_ );
00689     }
00690 
00691     xmog_array_iterator< ArrayType >    operator + ( difference_type diff )
00692     {
00693         return xmog_array_iterator< ArrayType >( array_, index_ + diff );
00694     }
00695 
00699     xmog_array_iterator< ArrayType > &  operator += ( difference_type diff )
00700     {
00701         index_ = index_ + diff;
00702         return *this;
00703     }
00704 
00705     xmog_array_iterator< ArrayType >    operator - ( difference_type diff )
00706     {
00707         return xmog_array_iterator< ArrayType >( array_, index_ - diff );
00708     }
00709 
00713     xmog_array_iterator< ArrayType > &  operator -= ( difference_type diff )
00714     {
00715         index_ = index_ - diff;
00716         return *this;
00717     }
00718 
00723     value_type operator[] ( jint ind )
00724     {
00725         return array_[ index_ + ind ];
00726     }
00727 
00731     value_type operator * ()
00732     {
00733         return array_[ index_ ];
00734     }
00735     
00739     xmog_array_iterator< ArrayType > &  operator ++ ()
00740     {
00741         ++index_;
00742         return *this;
00743     }
00744     
00748     xmog_array_iterator< ArrayType >    operator ++ ( int )
00749     {
00750         return xmog_array_iterator< ArrayType >( array_, index_++ );
00751     }
00752     
00756     xmog_array_iterator< ArrayType > &  operator -- ()
00757     {
00758         --index_;
00759         return *this;
00760     }
00761     
00765     xmog_array_iterator< ArrayType >    operator -- ( int )
00766     {
00767         return xmog_array_iterator< ArrayType >( array_, index_-- );
00768     }
00769 
00770 };
00771 
00772 
00778 class XMOG_DECLSPEC xmog_java_bool_array : public xmog_java_array
00779 {
00780 private:
00781 
00782     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
00783 
00784 public:
00785 
00789     typedef xmog_array_iterator<xmog_java_bool_array>   iterator;
00790 
00794     typedef xmog_bool   value_type;
00795 
00799     typedef ptrdiff_t   difference_type;
00800 
00804     xmog_java_bool_array();
00805 
00809     xmog_java_bool_array( const xmog_null & );
00810 
00814     xmog_java_bool_array( const xmog_java_bool_array &, xmog_localenv * env = NULL );
00815 
00819     xmog_java_bool_array( xmog_java_array * _ref, jint _index );
00820 
00824     xmog_java_bool_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
00825 
00829     xmog_java_bool_array( xmog_base * _delegate, bool _owns_delegate = true );
00830 
00834     xmog_java_bool_array( jobject _local, xmog_flags _flags );
00835 
00842     xmog_java_bool_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
00843 
00851     xmog_java_bool_array( bool * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
00852 
00856     iterator    begin()
00857     {
00858         return iterator( *this, 0 );
00859     }
00860 
00864     iterator    end()
00865     {
00866         return iterator( *this, length );
00867     }
00868 
00888     static xmog_java_bool_array dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
00889 
00898     void                        from_native( bool * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL );   
00899 
00908     void                        to_native( bool * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL ); 
00909 
00914     static xmog_java_dynamic *  get_dynamic();
00915 
00919     static xmog_java_class *    get_class();
00920 
00924     static xmog_java_class *    get_element_java_class();
00925 
00931     xmog_bool       operator [] ( jint index );
00932 
00946     void            set( jint index, bool v, xmog_localenv * env = NULL );
00947 
00953     bool            operator [] ( jint index ) const;
00954 
00965     bool            get( jint index, xmog_localenv * env ) const;
00966 
00970     xmog_java_bool_array &  operator = ( const xmog_java_bool_array & );
00971 
00972 };
00973 
00974 
00980 class XMOG_DECLSPEC xmog_java_jboolean_array : public xmog_java_array
00981 {
00982 private:
00983 
00984     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
00985 
00986 public:
00987 
00991     typedef xmog_array_iterator<xmog_java_jboolean_array>   iterator;
00992 
00996     typedef xmog_jboolean   value_type;
00997 
01001     typedef ptrdiff_t   difference_type;
01002 
01006     xmog_java_jboolean_array();
01007 
01011     xmog_java_jboolean_array( const xmog_null & );
01012 
01016     xmog_java_jboolean_array( const xmog_java_jboolean_array &, xmog_localenv * env = NULL );
01017 
01021     xmog_java_jboolean_array( xmog_java_array * _ref, jint _index );
01022 
01026     xmog_java_jboolean_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
01027 
01031     xmog_java_jboolean_array( xmog_base * _delegate, bool _owns_delegate = true );
01032 
01036     xmog_java_jboolean_array( jobject _local, xmog_flags _flags );
01037 
01044     xmog_java_jboolean_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
01045 
01053     xmog_java_jboolean_array( jboolean * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
01054 
01058     iterator    begin()
01059     {
01060         return iterator( *this, 0 );
01061     }
01062 
01066     iterator    end()
01067     {
01068         return iterator( *this, length );
01069     }
01070 
01090     static xmog_java_jboolean_array dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
01091 
01100     void                        from_native( jboolean * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL );   
01101 
01110     void                        to_native( jboolean * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL ); 
01111 
01116     static xmog_java_dynamic *  get_dynamic();
01117 
01121     static xmog_java_class *    get_class();
01122 
01126     static xmog_java_class *    get_element_java_class();
01127 
01133     xmog_jboolean   operator [] ( jint index );
01134 
01148     void            set( jint index, jboolean v, xmog_localenv * env = NULL );
01149 
01155     jboolean        operator [] ( jint index ) const;
01156 
01167     jboolean        get( jint index, xmog_localenv * env ) const;
01168 
01172     xmog_java_jboolean_array &  operator = ( const xmog_java_jboolean_array & );
01173 
01174 };
01175 
01176 
01177 
01183 class XMOG_DECLSPEC xmog_java_byte_array : public xmog_java_array
01184 {
01185 private:
01186 
01187     jarray      create( jbyte * buffer, jint size, xmog_flags flags, bool useNIO, xmog_localenv * env );
01188 
01189     xmog_base   buffer;
01190 
01191 public:
01192 
01196     typedef xmog_array_iterator<xmog_java_byte_array>   iterator;
01197 
01201     typedef xmog_byte   value_type;
01202 
01206     typedef ptrdiff_t   difference_type;
01207 
01211     xmog_java_byte_array();
01212 
01216     xmog_java_byte_array( const xmog_null & );
01217 
01221     xmog_java_byte_array( const xmog_java_byte_array &, xmog_localenv * env = NULL );
01222 
01226     xmog_java_byte_array( xmog_java_array * _ref, jint _index );
01227 
01231     xmog_java_byte_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
01232 
01236     xmog_java_byte_array( xmog_base * _delegate, bool _owns_delegate = true );
01237 
01241     xmog_java_byte_array( jobject _local, xmog_flags _flags );
01242 
01249     xmog_java_byte_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
01250 
01258     xmog_java_byte_array( jbyte * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
01259 
01271     xmog_java_byte_array( jbyte * arr, jsize size, bool useNIO, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
01272 
01276     ~xmog_java_byte_array();
01277 
01281     iterator    begin()
01282     {
01283         return iterator( *this, 0 );
01284     }
01285 
01289     iterator    end()
01290     {
01291         return iterator( *this, length );
01292     }
01293 
01313     static xmog_java_byte_array dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
01314 
01323     void                        from_native( jbyte * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL );  
01324 
01333     void                        to_native( jbyte * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL );    
01334 
01342     void                        to_native_nio( jbyte ** dest_arr, jlong * length, xmog_localenv * env = NULL ); 
01343 
01348     static xmog_java_dynamic *  get_dynamic();
01349 
01353     static xmog_java_class *    get_class();
01354 
01358     static xmog_java_class *    get_element_java_class();
01359 
01365     xmog_byte       operator [] ( jint index );
01366 
01380     void            set( jint index, jbyte v, xmog_localenv * env = NULL );
01381 
01387     jbyte           operator [] ( jint index ) const;
01388 
01399     jbyte           get( jint index, xmog_localenv * env ) const;
01400 
01404     xmog_java_byte_array &  operator = ( const xmog_java_byte_array & );
01405 
01406 };
01407 
01408 
01414 class XMOG_DECLSPEC xmog_java_char_array : public xmog_java_array
01415 {
01416 private:
01417 
01418     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
01419 
01420 public:
01421 
01425     typedef xmog_array_iterator<xmog_java_char_array>   iterator;
01426 
01430     typedef xmog_char   value_type;
01431 
01435     typedef ptrdiff_t   difference_type;
01436 
01440     xmog_java_char_array();
01441 
01445     xmog_java_char_array( const xmog_null & );
01446 
01450     xmog_java_char_array( const xmog_java_char_array & , xmog_localenv * env = NULL );
01451 
01455     xmog_java_char_array( xmog_java_array * _ref, jint _index );
01456 
01460     xmog_java_char_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
01461 
01465     xmog_java_char_array( xmog_base * _delegate, bool _owns_delegate = true );
01466 
01470     xmog_java_char_array( jobject _local, xmog_flags _flags );
01471 
01478     xmog_java_char_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
01479 
01487     xmog_java_char_array( jchar * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
01488 
01492     iterator    begin()
01493     {
01494         return iterator( *this, 0 );
01495     }
01496 
01500     iterator    end()
01501     {
01502         return iterator( *this, length );
01503     }
01504 
01524     static xmog_java_char_array dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
01525 
01534     void                        from_native( jchar * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL );  
01535 
01544     void                        to_native( jchar * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL );    
01545 
01550     static xmog_java_dynamic *  get_dynamic();
01551 
01555     static xmog_java_class *    get_class();
01556 
01560     static xmog_java_class *    get_element_java_class();
01561 
01567     xmog_char       operator [] ( jint index );
01568 
01582     void            set( jint index, jchar v, xmog_localenv * env = NULL );
01583 
01589     jchar           operator [] ( jint index ) const;
01590 
01601     jchar           get( jint index, xmog_localenv * env ) const;
01602 
01606     xmog_java_char_array &  operator = ( const xmog_java_char_array & );
01607 
01608 };
01609 
01610 
01616 class XMOG_DECLSPEC xmog_java_double_array : public xmog_java_array
01617 {
01618 private:
01619 
01620     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
01621 
01622 public:
01623 
01627     typedef xmog_array_iterator<xmog_java_double_array> iterator;
01628 
01632     typedef xmog_double value_type;
01633 
01637     typedef ptrdiff_t   difference_type;
01638 
01642     xmog_java_double_array();
01643 
01647     xmog_java_double_array( const xmog_null & );
01648 
01652     xmog_java_double_array( const xmog_java_double_array & , xmog_localenv * env = NULL );
01653 
01657     xmog_java_double_array( xmog_java_array * _ref, jint _index );
01658 
01662     xmog_java_double_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
01663 
01667     xmog_java_double_array( xmog_base * _delegate, bool _owns_delegate = true );
01668 
01672     xmog_java_double_array( jobject _local, xmog_flags _flags );
01673 
01680     xmog_java_double_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
01681 
01689     xmog_java_double_array( jdouble * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
01690 
01694     iterator    begin()
01695     {
01696         return iterator( *this, 0 );
01697     }
01698 
01702     iterator    end()
01703     {
01704         return iterator( *this, length );
01705     }
01706 
01726     static xmog_java_double_array   dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
01727 
01736     void                        from_native( jdouble * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL );    
01737 
01746     void                        to_native( jdouble * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL );  
01747 
01752     static xmog_java_dynamic *  get_dynamic();
01753 
01757     static xmog_java_class *    get_class();
01758 
01762     static xmog_java_class *    get_element_java_class();
01763 
01769     xmog_double     operator [] ( jint index );
01770 
01784     void            set( jint index, jdouble v, xmog_localenv * env = NULL );
01785 
01791     jdouble         operator [] ( jint index ) const;
01792 
01803     jdouble         get( jint index, xmog_localenv * env ) const;
01804 
01808     xmog_java_double_array &    operator = ( const xmog_java_double_array & );
01809 
01810 };
01811 
01812 
01818 class XMOG_DECLSPEC xmog_java_float_array : public xmog_java_array
01819 {
01820 private:
01821 
01822     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
01823 
01824 public:
01825 
01829     typedef xmog_array_iterator<xmog_java_float_array>  iterator;
01830 
01834     typedef xmog_float  value_type;
01835 
01839     typedef ptrdiff_t   difference_type;
01840 
01844     xmog_java_float_array();
01845 
01849     xmog_java_float_array( const xmog_null & );
01850 
01854     xmog_java_float_array( const xmog_java_float_array & , xmog_localenv * env = NULL );
01855 
01859     xmog_java_float_array( xmog_java_array * _ref, jint _index );
01860 
01864     xmog_java_float_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
01865 
01869     xmog_java_float_array( xmog_base * _delegate, bool _owns_delegate = true );
01870 
01874     xmog_java_float_array( jobject _local, xmog_flags _flags );
01875 
01882     xmog_java_float_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
01883 
01891     xmog_java_float_array( jfloat * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
01892 
01896     iterator    begin()
01897     {
01898         return iterator( *this, 0 );
01899     }
01900 
01904     iterator    end()
01905     {
01906         return iterator( *this, length );
01907     }
01908 
01928     static xmog_java_float_array    dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
01929 
01938     void                        from_native( jfloat * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL ); 
01939 
01948     void                        to_native( jfloat * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL );   
01949 
01954     static xmog_java_dynamic *  get_dynamic();
01955 
01959     static xmog_java_class *    get_class();
01960 
01964     static xmog_java_class *    get_element_java_class();
01965 
01971     xmog_float      operator [] ( jint index );
01972 
01986     void            set( jint index, jfloat v, xmog_localenv * env = NULL );
01987 
01993     jfloat          operator [] ( jint index ) const;
01994 
02005     jfloat          get( jint index, xmog_localenv * env ) const;
02006 
02010     xmog_java_float_array & operator = ( const xmog_java_float_array & );
02011 
02012 };
02013 
02014 
02020 class XMOG_DECLSPEC xmog_java_int_array : public xmog_java_array
02021 {
02022 private:
02023 
02024     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
02025 
02026 public:
02027 
02031     typedef xmog_array_iterator<xmog_java_int_array>    iterator;
02032 
02036     typedef xmog_int    value_type;
02037 
02041     typedef ptrdiff_t   difference_type;
02042 
02046     xmog_java_int_array();
02047 
02051     xmog_java_int_array( const xmog_null & );
02052 
02056     xmog_java_int_array( const xmog_java_int_array & , xmog_localenv * env = NULL );
02057 
02061     xmog_java_int_array( xmog_java_array * _ref, jint _index );
02062 
02066     xmog_java_int_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
02067 
02071     xmog_java_int_array( xmog_base * _delegate, bool _owns_delegate = true );
02072 
02076     xmog_java_int_array( jobject _local, xmog_flags _flags );
02077 
02084     xmog_java_int_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
02085 
02093     xmog_java_int_array( jint * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
02094 
02098     iterator    begin()
02099     {
02100         return iterator( *this, 0 );
02101     }
02102 
02106     iterator    end()
02107     {
02108         return iterator( *this, length );
02109     }
02110 
02130     static xmog_java_int_array  dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
02131 
02140     void                        from_native( jint * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL );   
02141 
02150     void                        to_native( jint * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL ); 
02151 
02156     static xmog_java_dynamic *  get_dynamic();
02157 
02161     static xmog_java_class *    get_class();
02162 
02166     static xmog_java_class *    get_element_java_class();
02167 
02173     xmog_int        operator [] ( jint index );
02174 
02188     void            set( jint index, jint v, xmog_localenv * env = NULL );
02189 
02195     jint            operator [] ( jint index ) const;
02196 
02207     jint            get( jint index, xmog_localenv * env ) const;
02208 
02212     xmog_java_int_array &   operator = ( const xmog_java_int_array & );
02213 
02214 };
02215 
02216 
02222 class XMOG_DECLSPEC xmog_java_long_array : public xmog_java_array
02223 {
02224 private:
02225 
02226     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
02227 
02228 public:
02229 
02233     typedef xmog_array_iterator<xmog_java_long_array>   iterator;
02234 
02238     typedef xmog_long   value_type;
02239 
02243     typedef ptrdiff_t   difference_type;
02244 
02248     xmog_java_long_array();
02249 
02253     xmog_java_long_array( const xmog_null & );
02254 
02258     xmog_java_long_array( const xmog_java_long_array & , xmog_localenv * env = NULL );
02259 
02263     xmog_java_long_array( xmog_java_array * _ref, jint _index );
02264 
02268     xmog_java_long_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
02269 
02273     xmog_java_long_array( xmog_base * _delegate, bool _owns_delegate = true );
02274 
02278     xmog_java_long_array( jobject _local, xmog_flags _flags );
02279 
02286     xmog_java_long_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
02287 
02295     xmog_java_long_array( jlong * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
02296 
02300     iterator    begin()
02301     {
02302         return iterator( *this, 0 );
02303     }
02304 
02308     iterator    end()
02309     {
02310         return iterator( *this, length );
02311     }
02312 
02332     static xmog_java_long_array dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
02333 
02342     void                        from_native( jlong * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL );  
02343 
02352     void                        to_native( jlong * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL );    
02353 
02358     static xmog_java_dynamic *  get_dynamic();
02359 
02363     static xmog_java_class *    get_class();
02364 
02368     static xmog_java_class *    get_element_java_class();
02369 
02375     xmog_long       operator [] ( jint index );
02376 
02390     void            set( jint index, jlong v, xmog_localenv * env = NULL );
02391 
02397     jlong           operator [] ( jint index ) const;
02398 
02409     jlong           get( jint index, xmog_localenv * env ) const;
02410 
02414     xmog_java_long_array &  operator = ( const xmog_java_long_array & );
02415 
02416 };
02417 
02418 
02424 class XMOG_DECLSPEC xmog_java_short_array : public xmog_java_array
02425 {
02426 private:
02427 
02428     jarray      create( jint size, xmog_flags flags, xmog_localenv * env );
02429 
02430 public:
02431 
02435     typedef xmog_array_iterator<xmog_java_short_array>  iterator;
02436 
02440     typedef xmog_short  value_type;
02441 
02445     typedef ptrdiff_t   difference_type;
02446 
02450     xmog_java_short_array();
02451 
02455     xmog_java_short_array( const xmog_null & );
02456 
02460     xmog_java_short_array( const xmog_java_short_array & , xmog_localenv * env = NULL );
02461 
02465     xmog_java_short_array( xmog_java_array * _ref, jint _index );
02466 
02470     xmog_java_short_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
02471 
02475     xmog_java_short_array( xmog_base * _delegate, bool _owns_delegate = true );
02476 
02480     xmog_java_short_array( jobject _local, xmog_flags _flags );
02481 
02488     xmog_java_short_array( jint size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL  );
02489 
02497     xmog_java_short_array( jshort * arr, jsize size, xmog_localenv * env = NULL, xmog_flags = xmog_base::GLOBAL );
02498 
02502     iterator    begin()
02503     {
02504         return iterator( *this, 0 );
02505     }
02506 
02510     iterator    end()
02511     {
02512         return iterator( *this, length );
02513     }
02514 
02534     static xmog_java_short_array    dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL );
02535 
02544     void                        from_native( jshort * src_arr, jint dest_start, jsize length, xmog_localenv * env = NULL ); 
02545 
02554     void                        to_native( jshort * dest_arr, jint src_start, jsize length, xmog_localenv * env = NULL );   
02555 
02560     static xmog_java_dynamic *  get_dynamic();
02561 
02565     static xmog_java_class *    get_class();
02566 
02570     static xmog_java_class *    get_element_java_class();
02571 
02577     xmog_short      operator [] ( jint index );
02578 
02592     void            set( jint index, jshort v, xmog_localenv * env = NULL );
02593 
02599     jshort          operator [] ( jint index ) const;
02600 
02611     jshort          get( jint index, xmog_localenv * env ) const;
02612 
02616     xmog_java_short_array & operator = ( const xmog_java_short_array & );
02617 
02618 };
02619 
02620 
02633 class XMOG_DECLSPEC xmog_java_object_array : public xmog_java_array
02634 {
02635 protected:
02636 
02645     jarray      create( jint size, xmog_java_class * clazz, xmog_flags flags, xmog_localenv * env );
02646 
02647 public:
02648 
02652     xmog_java_object_array();
02653 
02657     xmog_java_object_array( const xmog_null & );
02658 
02662     xmog_java_object_array( const xmog_java_object_array & , xmog_localenv * env = NULL );
02663 
02667     xmog_java_object_array( xmog_java_array * _ref, jint _index );
02668 
02672     xmog_java_object_array( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL );
02673 
02677     xmog_java_object_array( xmog_base * _delegate, bool _owns_delegate = true );
02678 
02682     xmog_java_object_array( jobject _local, xmog_flags _flags );
02683 
02692     xmog_java_object_array( jint size, xmog_java_class * clazz, xmog_localenv * env = NULL, xmog_flags flags = xmog_base::GLOBAL  );
02693 
02698     static xmog_java_dynamic *  get_dynamic();
02699 
02703     static xmog_java_class *    get_class();
02704 
02708     static xmog_java_class *    get_element_java_class();
02709 
02715     xmog_java_ref   operator [] ( jint index );
02716 
02730     void            set( jint index, jobject v, xmog_localenv * env = NULL );
02731 
02737     jobject         operator [] ( jint index ) const;
02738 
02749     jobject         get( jint index, xmog_localenv * env ) const;
02750 
02754     xmog_java_object_array &    operator = ( const xmog_java_object_array & );
02755 
02756 };
02757 
02758 
02759 
02760 template < class ElementType > class xmog_holder_template : public ElementType 
02761 {
02762 public:
02763 
02767     xmog_holder_template<ElementType>( xmog_java_array * _ref, jint _index ) :
02768         ElementType( _ref, _index )
02769     {
02770         // explicit type specifier required for g++ 3.4+
02771         this->ElementType::owner_ = _ref;
02772         this->ElementType::index_ = _index;
02773         this->ElementType::flags_ = xmog_base::ARRAY_ELEMENT | xmog_base::CACHE_INVALID;
02774     }
02775 
02779     xmog_holder_template<ElementType>( const xmog_holder_template<ElementType> & _rhs ) :
02780         ElementType()
02781     {
02782         // explicit type specifier required for g++ 3.4+
02783         this->ElementType::owner_ = _rhs.owner_.value();
02784         this->ElementType::index_ = _rhs.index_;
02785         this->ElementType::flags_ = _rhs.flags_;
02786 
02787         // just to make sure, we release the object 
02788         ((ElementType&)_rhs).owner_ = 0;
02789     }
02790 
02791     ElementType     operator = ( const xmog_holder_template<ElementType> & _rhs )
02792     {
02793         return this->ElementType::operator = ( _rhs );
02794     }
02795 
02796     ElementType     operator = ( const ElementType & _rhs )
02797     {
02798         return this->ElementType::operator = ( _rhs );
02799     }
02800 
02801     ElementType &   operator * ()
02802     {
02803         return *this;
02804     }
02805 };
02806 
02807 
02813 template < class ElementType > class xmog_java_array_template : public xmog_java_object_array
02814 {
02815 public:
02816 
02820     typedef xmog_array_iterator< xmog_java_array_template< ElementType > >  iterator;
02821 
02825     typedef xmog_holder_template< ElementType > value_type;
02826 
02830     typedef ptrdiff_t   difference_type;
02831 
02835     xmog_java_array_template<ElementType>() :
02836         xmog_java_object_array()
02837     {
02838     }
02839 
02843     xmog_java_array_template<ElementType>( const xmog_null & ) :
02844         xmog_java_object_array()
02845     {
02846     }
02847 
02852     xmog_java_array_template<ElementType>( const xmog_java_array_template<ElementType> & _rhs, xmog_localenv * _env = NULL ) :
02853         xmog_java_object_array( _rhs, _env )
02854     {
02855     }
02856 
02860     XMOG_EXPLICIT xmog_java_array_template<ElementType>( xmog_java_array * _ref, jint _index ) :
02861         xmog_java_object_array( _ref, _index )
02862     {
02863     }
02864 
02868     XMOG_EXPLICIT xmog_java_array_template<ElementType>( xmog_java_ref * _clazz_ref_array, xmog_java_dynamic * _dynamic, xmog_flags _flags = xmog_base::GLOBAL ) :
02869         xmog_java_object_array( _clazz_ref_array, _dynamic, _flags )
02870     {
02871     }
02872 
02879     XMOG_EXPLICIT xmog_java_array_template<ElementType>( xmog_base * _delegate, bool bOwnsDelegate ) :
02880         xmog_java_object_array( _delegate, bOwnsDelegate )
02881     {
02882     }
02883 
02887     XMOG_EXPLICIT xmog_java_array_template<ElementType>( jobject _local, xmog_flags _flags ) :
02888         xmog_java_object_array( _local, _flags )
02889     {
02890     }
02891 
02899     XMOG_EXPLICIT xmog_java_array_template<ElementType>( jint size, xmog_localenv * env = NULL, xmog_flags flags = xmog_base::GLOBAL  ) :
02900         xmog_java_object_array( size, ElementType::get_class(), env, flags )
02901     {
02902         //owner_ = create( size, ElementType::get_class(), flags, env );
02903         //flags_ = xmog_base::STAND_ALONE | flags;
02904     }
02905 
02906     ~xmog_java_array_template<ElementType>()
02907     {
02908     }
02909 
02913     iterator    begin()
02914     {
02915         return iterator( *this, 0 );
02916     }
02917 
02921     iterator    end()
02922     {
02923         return iterator( *this, length );
02924     }
02925 
02945     static xmog_java_array_template<ElementType>    dyna_cast( const xmog_java_ref & _rhs, xmog_localenv * p_lxenv = NULL, xmog_flags flags = xmog_base::GLOBAL )
02946     {
02947         if( p_lxenv == NULL )
02948             p_lxenv = xmog_localenv::get_instance( p_lxenv );
02949         
02950         return xmog_java_array_template<ElementType>( get_class()->from( _rhs, flags, p_lxenv ), flags );
02951     }
02952 
02956     xmog_java_array_template<ElementType> & operator = ( const xmog_java_array_template<ElementType> & _rhs )
02957     {
02958         copy_( _rhs );
02959         return *this;
02960     }
02961 
02966     static xmog_java_dynamic *  get_dynamic()
02967     {
02968         return &xmog_java_element::theElement;
02969     }
02970 
02974     static xmog_java_class *    get_class()
02975     {
02976         return ElementType::get_class()->get_array_class();
02977     }
02978 
02982     static xmog_java_class *    get_element_java_class()
02983     {
02984         return ElementType::get_class();
02985     }
02986 
02992     xmog_holder_template<ElementType>       operator [] ( jint index )
02993     {
02994         return xmog_holder_template<ElementType>( (xmog_java_array*)this, index );
02995     }
02996 
02997 
03001     xmog_holder_template<ElementType>       operator [] ( jint index ) const
03002     {
03003         return xmog_holder_template<ElementType>( (xmog_java_array*)this, index );
03004     }
03005 
03006 };
03007 
03008 
03009 #if (XMOG_PRE_3_0_SUPPORT == 1 )
03010 
03018 typedef xmog_java_bool_array    jcpp_bool_array;
03019 
03027 typedef xmog_java_byte_array    jcpp_byte_array;
03028 
03036 typedef xmog_java_char_array    jcpp_char_array;
03037 
03045 typedef xmog_java_double_array  jcpp_double_array;
03046 
03054 typedef xmog_java_float_array   jcpp_float_array;
03055 
03063 typedef xmog_java_int_array     jcpp_int_array;
03064 
03072 typedef xmog_java_long_array    jcpp_long_array;
03073 
03081 typedef xmog_java_short_array   jcpp_short_array;
03082 
03083 #endif
03084 
03085 #endif /* xmog_java_array_inc */

Generated on Wed May 31 14:01:19 2006 for Shared Codemesh Runtime Library API Reference by  doxygen 1.4.1