00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _EPFUNC_H
00011 #define _EPFUNC_H
00012
00018 template< class T > T* getEpFuncData( const Eref& e )
00019 {
00020 return reinterpret_cast< T* >( e.data() ) ;
00021 }
00022
00039 template<> Neutral* getEpFuncData< Neutral >( const Eref& e );
00040
00041
00042
00043
00049 template< class T > class EpFunc0: public OpFunc0Base
00050 {
00051 public:
00052 EpFunc0( void ( T::*func )( const Eref& e ) )
00053 : func_( func )
00054 {;}
00055
00056 void op( const Eref& e ) const {
00057 ( reinterpret_cast< T* >( e.data() )->*func_ )( e );
00058 }
00059
00060 private:
00061 void ( T::*func_ )( const Eref& e );
00062 };
00063
00064 template< class T, class A > class EpFunc1: public OpFunc1Base< A >
00065 {
00066 public:
00067 EpFunc1( void ( T::*func )( const Eref&, A ) )
00068 : func_( func )
00069 {;}
00070
00071 void op( const Eref& e, A arg ) const {
00072 ( reinterpret_cast< T* >( e.data() )->*func_ )( e, arg );
00073 }
00074
00075 private:
00076 void ( T::*func_ )( const Eref& e, A );
00077 };
00078
00079 template< class T, class A1, class A2 > class EpFunc2:
00080 public OpFunc2Base< A1, A2 >
00081 {
00082 public:
00083 EpFunc2( void ( T::*func )( const Eref&, A1, A2 ) )
00084 : func_( func )
00085 {;}
00086
00087 void op( const Eref& e, A1 arg1, A2 arg2 ) const {
00088 ( reinterpret_cast< T* >( e.data() )->*func_ )( e, arg1, arg2 );
00089 }
00090
00091 private:
00092 void ( T::*func_ )( const Eref& e, A1, A2 );
00093 };
00094
00095 template< class T, class A1, class A2, class A3 > class EpFunc3:
00096 public OpFunc3Base< A1, A2, A3 >
00097 {
00098 public:
00099 EpFunc3( void ( T::*func )( const Eref&, A1, A2, A3 ) )
00100 : func_( func )
00101 {;}
00102
00103 void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3 ) const {
00104 ( reinterpret_cast< T* >( e.data() )->*func_ )(
00105 e, arg1, arg2, arg3 );
00106 }
00107
00108 private:
00109 void ( T::*func_ )( const Eref& e, A1, A2, A3 );
00110 };
00111
00112 template< class T, class A1, class A2, class A3, class A4 > class EpFunc4:
00113 public OpFunc4Base< A1, A2, A3, A4 >
00114 {
00115 public:
00116 EpFunc4( void ( T::*func )( const Eref&, A1, A2, A3, A4 ) )
00117 : func_( func )
00118 {;}
00119
00120 void op( const Eref& e, A1 arg1, A2 arg2, A3 arg3, A4 arg4 ) const {
00121 ( reinterpret_cast< T* >( e.data() )->*func_ )(
00122 e, arg1, arg2, arg3, arg4 );
00123 }
00124
00125 private:
00126 void ( T::*func_ )( const Eref& e, A1, A2, A3, A4 );
00127 };
00128
00129 template< class T, class A1, class A2, class A3, class A4, class A5 >
00130 class EpFunc5: public OpFunc5Base< A1, A2, A3, A4, A5 >
00131 {
00132 public:
00133 EpFunc5( void ( T::*func )( const Eref&, A1, A2, A3, A4, A5 ) )
00134 : func_( func )
00135 {;}
00136
00137 void op( const Eref& e,
00138 A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5 ) const {
00139 ( reinterpret_cast< T* >( e.data() )->*func_ )(
00140 e, arg1, arg2, arg3, arg4, arg5 );
00141 }
00142 private:
00143 void ( T::*func_ )( const Eref& e, A1, A2, A3, A4, A5 );
00144 };
00145
00146 template< class T,
00147 class A1, class A2, class A3, class A4, class A5, class A6 >
00148 class EpFunc6: public OpFunc6Base< A1, A2, A3, A4, A5, A6 >
00149 {
00150 public:
00151 EpFunc6( void ( T::*func )( const Eref&, A1, A2, A3, A4, A5, A6 ) )
00152 : func_( func )
00153 {;}
00154
00155 void op( const Eref& e,
00156 A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6 )
00157 const {
00158 ( reinterpret_cast< T* >( e.data() )->*func_ )(
00159 e, arg1, arg2, arg3, arg4, arg5, arg6 );
00160 }
00161
00162 private:
00163 void ( T::*func_ )( const Eref& e, A1, A2, A3, A4, A5, A6 );
00164 };
00165
00174 template< class T, class A > class GetEpFunc: public GetOpFuncBase< A >
00175 {
00176 public:
00177 GetEpFunc( A ( T::*func )( const Eref& e ) const )
00178 : func_( func )
00179 {;}
00180
00181 void op( const Eref& e, vector< A >* ret ) const {
00182 ret->push_back( returnOp( e ) );
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 A returnOp( const Eref& e ) const {
00195 return ( getEpFuncData< T >( e )->*func_ )( e );
00196 }
00197
00198 private:
00199 A ( T::*func_ )( const Eref& e ) const;
00200 };
00201
00202
00212 template< class T, class L, class A > class GetEpFunc1:
00213 public LookupGetOpFuncBase< L, A >
00214 {
00215 public:
00216 GetEpFunc1( A ( T::*func )( const Eref& e, L ) const )
00217 : func_( func )
00218 {;}
00219
00220
00221 void op( const Eref& e, L index, ObjId recipient, FuncId fid )
00222 const {
00223 const OpFunc *f = recipient.element()->cinfo()->getOpFunc( fid);
00224 const OpFunc1Base< A >* recvOpFunc =
00225 dynamic_cast< const OpFunc1Base< A >* >( f );
00226 assert( recvOpFunc );
00227 recvOpFunc->op( recipient.eref(), returnOp( e, index ) );
00228 }
00229
00230 A returnOp( const Eref& e, const L& index ) const {
00231 return ( reinterpret_cast< T* >( e.data() )->*func_)(
00232 e, index );
00233 }
00234
00235 private:
00236 A ( T::*func_ )( const Eref& e, L ) const;
00237 };
00238
00239 #endif //_EPFUNC_H