00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _SRC_FINFO_H
00010 #define _SRC_FINFO_H
00011
00012 #ifdef CYMOOSE
00013
00014 #include "../basecode/Finfo.h"
00015 #include "../basecode/header.h"
00016
00017 #endif
00018
00024 class SrcFinfo: public Finfo
00025 {
00026 public:
00027 SrcFinfo( const string& name, const string& doc );
00028
00029 ~SrcFinfo() {;}
00030
00031 void registerFinfo( Cinfo* c );
00032
00034
00035 bool strSet( const Eref& tgt, const string& field,
00036 const string& arg ) const {
00037 return 0;
00038 }
00039
00040 bool strGet( const Eref& tgt, const string& field,
00041 string& returnValue ) const {
00042 return 0;
00043 }
00044
00045 BindIndex getBindIndex() const;
00046 void setBindIndex( BindIndex b );
00047
00051 bool checkTarget( const Finfo* target ) const;
00052
00056 bool addMsg( const Finfo* target, ObjId mid, Element* src ) const;
00057
00062 virtual void sendBuffer( const Eref& e, double* buf )
00063 const = 0;
00064
00065 static const BindIndex BadBindIndex;
00066 private:
00070 unsigned short bindIndex_;
00071 };
00072
00076 class SrcFinfo0: public SrcFinfo
00077 {
00078 public:
00079
00080 SrcFinfo0( const string& name, const string& doc );
00081 ~SrcFinfo0() {;}
00082
00083 void send( const Eref& e ) const;
00084
00085 void sendBuffer( const Eref& e, double* buf ) const;
00086
00087 string rttiType() const {
00088 return "void";
00089 }
00090
00091 private:
00092 };
00093
00094 template< class A > class OpFunc1Base;
00095
00096
00097 template < class T > class SrcFinfo1: public SrcFinfo
00098 {
00099 public:
00100 ~SrcFinfo1() {;}
00101
00102 SrcFinfo1( const string& name, const string& doc )
00103 : SrcFinfo( name, doc )
00104 { ; }
00105
00106 void send( const Eref& er, T arg ) const
00107 {
00108 const vector< MsgDigest >& md = er.msgDigest( getBindIndex() );
00109 for ( vector< MsgDigest >::const_iterator
00110 i = md.begin(); i != md.end(); ++i ) {
00111 const OpFunc1Base< T >* f =
00112 dynamic_cast< const OpFunc1Base< T >* >( i->func );
00113 assert( f );
00114 for ( vector< Eref >::const_iterator
00115 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00116 if ( j->dataIndex() == ALLDATA ) {
00117 Element* e = j->element();
00118 unsigned int start = e->localDataStart();
00119 unsigned int end = start + e->numLocalData();
00120 for ( unsigned int k = start; k < end; ++k )
00121 f->op( Eref( e, k ), arg );
00122 } else {
00123 f->op( *j, arg );
00124
00125
00126
00127
00128
00129 }
00130 }
00131 }
00132 }
00133
00134 void sendTo( const Eref& er, Id tgt, T arg ) const
00135 {
00136 const vector< MsgDigest >& md = er.msgDigest( getBindIndex() );
00137 for ( vector< MsgDigest >::const_iterator
00138 i = md.begin(); i != md.end(); ++i ) {
00139 const OpFunc1Base< T >* f =
00140 dynamic_cast< const OpFunc1Base< T >* >( i->func );
00141 assert( f );
00142 for ( vector< Eref >::const_iterator
00143 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00144 if ( j->element() != tgt.element() )
00145 continue;
00146 if ( j->dataIndex() == ALLDATA ) {
00147 Element* e = j->element();
00148 unsigned int start = e->localDataStart();
00149 unsigned int end = start + e->numLocalData();
00150 for ( unsigned int k = start; k < end; ++k )
00151 f->op( Eref( e, k ), arg );
00152 } else {
00153 f->op( *j, arg );
00154
00155
00156
00157
00158
00159 }
00160 }
00161 }
00162 }
00163
00169 void sendVec( const Eref& er, const vector< T >& arg ) const
00170 {
00171 if ( arg.size() == 0 )
00172 return;
00173 const vector< MsgDigest >& md = er.msgDigest( getBindIndex() );
00174 unsigned int argPos = 0;
00175 for ( vector< MsgDigest >::const_iterator
00176 i = md.begin(); i != md.end(); ++i ) {
00177 const OpFunc1Base< T >* f =
00178 dynamic_cast< const OpFunc1Base< T >* >( i->func );
00179 assert( f );
00180 for ( vector< Eref >::const_iterator
00181 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00182 if ( j->dataIndex() == ALLDATA ) {
00183 Element* e = j->element();
00184 unsigned int start = e->localDataStart();
00185 unsigned int end = start + e->numLocalData();
00186 for ( unsigned int k = start; k < end; ++k ) {
00187 f->op( Eref( e, k ), arg[ argPos++ ] );
00188 if ( argPos >= arg.size() )
00189 argPos = 0;
00190 }
00191 } else {
00192 f->op( *j, arg[ argPos++ ] );
00193 if ( argPos >= arg.size() )
00194 argPos = 0;
00195
00196
00197
00198
00199
00200 }
00201 }
00202 }
00203 }
00204
00205 void sendBuffer( const Eref& e, double* buf ) const
00206 {
00207 send( e, Conv< T >::buf2val( &buf ) );
00208 }
00209
00210 string rttiType() const {
00211 return Conv<T>::rttiType();
00212 }
00213 private:
00214 };
00215
00216
00217 template< class A1, class A2 > class OpFunc2Base;
00218
00219 template < class T1, class T2 > class SrcFinfo2: public SrcFinfo
00220 {
00221 public:
00222 ~SrcFinfo2() {;}
00223
00224 SrcFinfo2( const string& name, const string& doc )
00225 : SrcFinfo( name, doc )
00226 { ; }
00227
00228 void send( const Eref& e, const T1& arg1, const T2& arg2 ) const
00229 {
00230 const vector< MsgDigest >& md = e.msgDigest( getBindIndex() );
00231 for ( vector< MsgDigest >::const_iterator
00232 i = md.begin(); i != md.end(); ++i ) {
00233 const OpFunc2Base< T1, T2 >* f =
00234 dynamic_cast< const OpFunc2Base< T1, T2 >* >( i->func );
00235 assert( f );
00236 for ( vector< Eref >::const_iterator
00237 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00238 if ( j->dataIndex() == ALLDATA ) {
00239 Element* e = j->element();
00240 unsigned int start = e->localDataStart();
00241 unsigned int end = start + e->numData();
00242 for ( unsigned int k = start; k < end; ++k )
00243 f->op( Eref( e, k ), arg1, arg2 );
00244 } else {
00245 f->op( *j, arg1, arg2 );
00246 }
00247 }
00248 }
00249 }
00250
00251 void sendTo( const Eref& e, Id tgt,
00252 const T1& arg1, const T2& arg2 ) const
00253 {
00254 const vector< MsgDigest >& md = e.msgDigest( getBindIndex() );
00255 for ( vector< MsgDigest >::const_iterator
00256 i = md.begin(); i != md.end(); ++i ) {
00257 const OpFunc2Base< T1, T2 >* f =
00258 dynamic_cast< const OpFunc2Base< T1, T2 >* >( i->func );
00259 assert( f );
00260 for ( vector< Eref >::const_iterator
00261 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00262 if ( j->element() != tgt.element() )
00263 continue;
00264 if ( j->dataIndex() == ALLDATA ) {
00265 Element* e = j->element();
00266 unsigned int start = e->localDataStart();
00267 unsigned int end = start + e->numData();
00268 for ( unsigned int k = start; k < end; ++k )
00269 f->op( Eref( e, k ), arg1, arg2 );
00270 } else {
00271 f->op( *j, arg1, arg2 );
00272 }
00273 }
00274 }
00275 }
00276
00277 void sendBuffer( const Eref& e, double* buf ) const
00278 {
00279
00280
00281
00282
00283
00284 const T1& arg1 = Conv< T1 >::buf2val( &buf );
00285 send( e, arg1, Conv< T2 >::buf2val( &buf ) );
00286 }
00287
00288 string rttiType() const {
00289 return Conv<T1>::rttiType() + "," + Conv< T2 >::rttiType();
00290 }
00291
00292 private:
00293 };
00294
00295 template< class A1, class A2, class A3 > class OpFunc3Base;
00296 template < class T1, class T2, class T3 > class SrcFinfo3: public SrcFinfo
00297 {
00298 public:
00299 ~SrcFinfo3() {;}
00300
00301 SrcFinfo3( const string& name, const string& doc )
00302 : SrcFinfo( name, doc )
00303 { ; }
00304
00305 void send( const Eref& e,
00306 const T1& arg1, const T2& arg2, const T3& arg3 ) const
00307 {
00308 const vector< MsgDigest >& md = e.msgDigest( getBindIndex() );
00309 for ( vector< MsgDigest >::const_iterator
00310 i = md.begin(); i != md.end(); ++i ) {
00311 const OpFunc3Base< T1, T2, T3 >* f =
00312 dynamic_cast< const OpFunc3Base< T1, T2, T3 >* >(
00313 i->func );
00314 assert( f );
00315 for ( vector< Eref >::const_iterator
00316 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00317 if ( j->dataIndex() == ALLDATA ) {
00318 Element* e = j->element();
00319 unsigned int start = e->localDataStart();
00320 unsigned int end = start + e->numData();
00321 for ( unsigned int k = start; k < end; ++k )
00322 f->op( Eref( e, k ), arg1, arg2, arg3 );
00323 } else {
00324 f->op( *j, arg1, arg2, arg3 );
00325 }
00326 }
00327 }
00328 }
00329
00330 void sendBuffer( const Eref& e, double* buf ) const
00331 {
00332 const T1& arg1 = Conv< T1 >::buf2val( &buf );
00333 const T2& arg2 = Conv< T2 >::buf2val( &buf );
00334 send( e, arg1, arg2, Conv< T3 >::buf2val( &buf ) );
00335 }
00336
00337 string rttiType() const {
00338 return Conv<T1>::rttiType() + "," + Conv< T2 >::rttiType() +
00339 "," + Conv<T3>::rttiType();
00340 }
00341
00342 private:
00343 };
00344
00345 template< class A1, class A2, class A3, class A4 > class OpFunc4Base;
00346 template < class T1, class T2, class T3, class T4 > class SrcFinfo4: public SrcFinfo
00347 {
00348 public:
00349 ~SrcFinfo4() {;}
00350
00351 SrcFinfo4( const string& name, const string& doc )
00352 : SrcFinfo( name, doc )
00353 { ; }
00354
00355
00356 void send( const Eref& e,
00357 const T1& arg1, const T2& arg2,
00358 const T3& arg3, const T4& arg4 ) const
00359 {
00360 const vector< MsgDigest >& md = e.msgDigest( getBindIndex() );
00361 for ( vector< MsgDigest >::const_iterator
00362 i = md.begin(); i != md.end(); ++i ) {
00363 const OpFunc4Base< T1, T2, T3, T4 >* f =
00364 dynamic_cast< const OpFunc4Base< T1, T2, T3, T4 >* >(
00365 i->func );
00366 assert( f );
00367 for ( vector< Eref >::const_iterator
00368 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00369 if ( j->dataIndex() == ALLDATA ) {
00370 Element* e = j->element();
00371 unsigned int start = e->localDataStart();
00372 unsigned int end = start + e->numData();
00373 for ( unsigned int k = start; k < end; ++k )
00374 f->op( Eref( e, k ), arg1, arg2, arg3, arg4 );
00375 } else {
00376 f->op( *j, arg1, arg2, arg3, arg4 );
00377 }
00378 }
00379 }
00380 }
00381
00382 void sendBuffer( const Eref& e, double* buf ) const
00383 {
00384 const T1& arg1 = Conv< T1 >::buf2val( &buf );
00385 const T2& arg2 = Conv< T2 >::buf2val( &buf );
00386 const T3& arg3 = Conv< T3 >::buf2val( &buf );
00387 send( e, arg1, arg2, arg3, Conv< T4 >::buf2val( &buf ) );
00388 }
00389
00390 string rttiType() const {
00391 return Conv<T1>::rttiType() + "," + Conv< T2 >::rttiType() +
00392 "," + Conv<T3>::rttiType() + "," + Conv< T4 >::rttiType();
00393 }
00394
00395 private:
00396 };
00397
00398 template< class A1, class A2, class A3, class A4, class A5 >
00399 class OpFunc5Base;
00400 template < class T1, class T2, class T3, class T4, class T5 > class SrcFinfo5: public SrcFinfo
00401 {
00402 public:
00403 ~SrcFinfo5() {;}
00404
00405 SrcFinfo5( const string& name, const string& doc )
00406 : SrcFinfo( name, doc )
00407 { ; }
00408
00409
00410 void send( const Eref& e,
00411 const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4,
00412 const T5& arg5 ) const
00413 {
00414 const vector< MsgDigest >& md = e.msgDigest( getBindIndex() );
00415 for ( vector< MsgDigest >::const_iterator
00416 i = md.begin(); i != md.end(); ++i ) {
00417 const OpFunc5Base< T1, T2, T3, T4, T5 >* f =
00418 dynamic_cast<
00419 const OpFunc5Base< T1, T2, T3, T4, T5 >* >( i->func );
00420 assert( f );
00421 for ( vector< Eref >::const_iterator
00422 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00423 if ( j->dataIndex() == ALLDATA ) {
00424 Element* e = j->element();
00425 unsigned int start = e->localDataStart();
00426 unsigned int end = start + e->numData();
00427 for ( unsigned int k = start; k < end; ++k )
00428 f->op( Eref( e, k ),
00429 arg1, arg2, arg3, arg4, arg5 );
00430 } else {
00431 f->op( *j, arg1, arg2, arg3, arg4, arg5 );
00432 }
00433 }
00434 }
00435 }
00436
00437 void sendBuffer( const Eref& e, double* buf ) const
00438 {
00439 const T1& arg1 = Conv< T1 >::buf2val( &buf );
00440 const T2& arg2 = Conv< T2 >::buf2val( &buf );
00441 const T3& arg3 = Conv< T3 >::buf2val( &buf );
00442 const T4& arg4 = Conv< T4 >::buf2val( &buf );
00443 send( e, arg1, arg2, arg3, arg4, Conv< T5 >::buf2val( &buf ) );
00444 }
00445
00446 string rttiType() const {
00447 return Conv<T1>::rttiType() + "," + Conv< T2 >::rttiType() +
00448 "," + Conv<T3>::rttiType() + "," + Conv< T4 >::rttiType() +
00449 "," + Conv<T5>::rttiType();
00450 }
00451
00452 private:
00453 };
00454
00455
00456 template< class A1, class A2, class A3, class A4, class A5, class A6 >
00457 class OpFunc6Base;
00458 template < class T1, class T2, class T3, class T4, class T5, class T6 > class SrcFinfo6: public SrcFinfo
00459 {
00460 public:
00461 ~SrcFinfo6() {;}
00462
00463 SrcFinfo6( const string& name, const string& doc )
00464 : SrcFinfo( name, doc )
00465 { ; }
00466
00467 void send( const Eref& e,
00468 const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4,
00469 const T5& arg5, const T6& arg6 ) const
00470 {
00471 const vector< MsgDigest >& md = e.msgDigest( getBindIndex() );
00472 for ( vector< MsgDigest >::const_iterator
00473 i = md.begin(); i != md.end(); ++i ) {
00474 const OpFunc6Base< T1, T2, T3, T4, T5, T6 >* f =
00475 dynamic_cast<
00476 const OpFunc6Base< T1, T2, T3, T4, T5, T6 >* >(
00477 i->func );
00478 assert( f );
00479 for ( vector< Eref >::const_iterator
00480 j = i->targets.begin(); j != i->targets.end(); ++j ) {
00481 if ( j->dataIndex() == ALLDATA ) {
00482 Element* e = j->element();
00483 unsigned int start = e->localDataStart();
00484 unsigned int end = start + e->numData();
00485 for ( unsigned int k = start; k < end; ++k )
00486 f->op( Eref( e, k ),
00487 arg1, arg2, arg3, arg4, arg5, arg6 );
00488 } else {
00489 f->op( *j, arg1, arg2, arg3, arg4, arg5, arg6 );
00490 }
00491 }
00492 }
00493 }
00494
00495 void sendBuffer( const Eref& e, double* buf ) const
00496 {
00497 const T1& arg1 = Conv< T1 >::buf2val( &buf );
00498 const T2& arg2 = Conv< T2 >::buf2val( &buf );
00499 const T3& arg3 = Conv< T3 >::buf2val( &buf );
00500 const T4& arg4 = Conv< T4 >::buf2val( &buf );
00501 const T5& arg5 = Conv< T5 >::buf2val( &buf );
00502 send( e, arg1, arg2, arg3, arg4, arg5, Conv< T6 >::buf2val( &buf ) );
00503 }
00504
00505 string rttiType() const {
00506 return Conv<T1>::rttiType() + "," + Conv< T2 >::rttiType() +
00507 "," + Conv<T3>::rttiType() + "," + Conv< T4 >::rttiType() +
00508 "," + Conv<T5>::rttiType() + "," + Conv< T6 >::rttiType();
00509 }
00510
00511 private:
00512 };
00513
00514 #endif // _SRC_FINFO_H