00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _OPFUNC_H
00011 #define _OPFUNC_H
00012
00013 template< class T > class OpFunc0: public OpFunc0Base
00014 {
00015 public:
00016 OpFunc0( void ( T::*func )( ) )
00017 : func_( func )
00018 {;}
00019
00020 void op( const Eref& e ) const {
00021 (reinterpret_cast< T* >( e.data() )->*func_)();
00022 }
00023 private:
00024 void ( T::*func_ )( );
00025 };
00026
00027 template< class T, class A > class OpFunc1: public OpFunc1Base<A>
00028 {
00029 public:
00030 OpFunc1( void ( T::*func )( A ) )
00031 : func_( func )
00032 {;}
00033 void op( const Eref& e, A arg ) const {
00034 (reinterpret_cast< T* >( e.data() )->*func_)( arg );
00035 }
00036 private:
00037 void ( T::*func_ )( A );
00038 };
00039
00040 template< class T, class A1, class A2 > class OpFunc2:
00041 public OpFunc2Base< A1, A2 >
00042 {
00043 public:
00044 OpFunc2( void ( T::*func )( A1, A2 ) )
00045 : func_( func )
00046 {;}
00047
00048 void op( const Eref& e, A1 arg1, A2 arg2 ) const {
00049 (reinterpret_cast< T* >( e.data() )->*func_)( arg1, arg2 );
00050 }
00051
00052 private:
00053 void ( T::*func_ )( A1, A2 );
00054 };
00055
00056 template< class T, class A1, class A2, class A3 > class OpFunc3:
00057 public OpFunc3Base< A1, A2, A3 >
00058 {
00059 public:
00060 OpFunc3( void ( T::*func )( A1, A2, A3 ) )
00061 : func_( func )
00062 {;}
00063 void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3 ) const {
00064 (reinterpret_cast< T* >( e.data() )->*func_)( arg1, arg2, arg3);
00065 }
00066 private:
00067 void ( T::*func_ )( A1, A2, A3 );
00068 };
00069
00070 template< class T, class A1, class A2, class A3, class A4 > class OpFunc4:
00071 public OpFunc4Base< A1, A2, A3, A4 >
00072 {
00073 public:
00074 OpFunc4( void ( T::*func )( A1, A2, A3, A4 ) )
00075 : func_( func )
00076 {;}
00077
00078 void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3, A4 arg4 ) const {
00079 (reinterpret_cast< T* >( e.data() )->*func_)(
00080 arg1, arg2, arg3, arg4 );
00081 }
00082
00083 private:
00084 void ( T::*func_ )( A1, A2, A3, A4 );
00085 };
00086
00087 template< class T, class A1, class A2, class A3, class A4, class A5 >
00088 class OpFunc5: public OpFunc5Base< A1, A2, A3, A4, A5 >
00089 {
00090 public:
00091 OpFunc5( void ( T::*func )( A1, A2, A3, A4, A5 ) )
00092 : func_( func )
00093 {;}
00094
00095 void op( const Eref& e,
00096 A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5 ) const {
00097 (reinterpret_cast< T* >( e.data() )->*func_)(
00098 arg1, arg2, arg3, arg4, arg5 );
00099 }
00100
00101 private:
00102 void ( T::*func_ )( A1, A2, A3, A4, A5 );
00103 };
00104
00105
00106 template< class T,
00107 class A1, class A2, class A3, class A4, class A5, class A6 >
00108 class OpFunc6: public OpFunc6Base< A1, A2, A3, A4, A5, A6 >
00109 {
00110 public:
00111 OpFunc6( void ( T::*func )( A1, A2, A3, A4, A5, A6 ) )
00112 : func_( func )
00113 {;}
00114
00115 void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3, A4 arg4,
00116 A5 arg5, A6 arg6 ) const {
00117 (reinterpret_cast< T* >( e.data() )->*func_)(
00118 arg1, arg2, arg3, arg4, arg5, arg6 );
00119 }
00120
00121 private:
00122 void ( T::*func_ )( A1, A2, A3, A4, A5, A6 );
00123 };
00124
00125
00134 template< class T, class A > class GetOpFunc: public GetOpFuncBase< A >
00135 {
00136 public:
00137 GetOpFunc( A ( T::*func )() const )
00138 : func_( func )
00139 {;}
00140
00141 void op( const Eref& e, vector< A >* ret ) const {
00142 ret->push_back( returnOp( e ) );
00143 }
00144
00145 A returnOp( const Eref& e ) const {
00146 return ( reinterpret_cast< T* >( e.data() )->*func_)();
00147 }
00148
00149 private:
00150 A ( T::*func_ )() const;
00151 };
00152
00164 template< class T, class L, class A > class GetOpFunc1:
00165 public LookupGetOpFuncBase< L, A >
00166 {
00167 public:
00168 GetOpFunc1( A ( T::*func )( L ) const )
00169 : func_( func )
00170 {;}
00171
00183 void op( const Eref& e, L index, ObjId recipient, FuncId fid )
00184 const {
00185 const OpFunc *f = recipient.element()->cinfo()->getOpFunc( fid);
00186 const OpFunc1Base< A >* recvOpFunc =
00187 dynamic_cast< const OpFunc1Base< A >* >( f );
00188 assert( recvOpFunc );
00189 recvOpFunc->op( recipient.eref(), returnOp( e, index ) );
00190 }
00191
00193 A returnOp( const Eref& e, const L& index ) const {
00194 return ( reinterpret_cast< T* >( e.data() )->*func_)( index );
00195 }
00196
00197 private:
00198 A ( T::*func_ )( L ) const;
00199 };
00200
00201 #endif // _OPFUNC_H