00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _ELEMENT_H
00010 #define _ELEMENT_H
00011
00012 class SrcFinfo;
00013 class FuncOrder;
00014
00020 class Element
00021 {
00022 public:
00034 Element( Id id, const Cinfo* c, const string& name );
00035
00039 virtual ~Element();
00040
00044 virtual Element* copyElement( Id newParent, Id newId,
00045 unsigned int n, bool toGlobal ) const = 0;
00047
00049
00053 const string& getName() const;
00054
00058 void setName( const string& val );
00059
00061 virtual unsigned int numData() const = 0;
00062
00064 virtual unsigned int numLocalData() const = 0;
00065
00067 virtual unsigned int localDataStart() const = 0;
00068
00070 virtual unsigned int numField( unsigned int rawIndex ) const = 0;
00071
00076 virtual unsigned int totNumLocalField() const = 0;
00077
00079 virtual unsigned int getNode( unsigned int dataIndex ) const = 0;
00080
00082 virtual unsigned int startDataIndex( unsigned int nodeNum ) const = 0;
00083
00087 virtual unsigned int rawIndex( unsigned int dataIndex ) const = 0;
00088
00092 Id id() const;
00093
00098 virtual bool hasFields() const = 0;
00099
00101 virtual bool isGlobal() const = 0;
00102
00105 virtual unsigned int getNumOnNode( unsigned int node ) const = 0;
00106
00112 int getTick() const;
00113
00122 void setTick( int t );
00123
00128 void innerSetTick( unsigned int tick );
00129
00131
00133
00149 virtual char* data( unsigned int rawIndex,
00150 unsigned int fieldIndex = 0 ) const = 0;
00151
00156 virtual void resize( unsigned int newNumData ) = 0;
00157
00162 virtual void resizeField(
00163 unsigned int rawIndex, unsigned int newNumField ) = 0;
00164
00166
00167
00173 void addMsg( ObjId mid );
00174
00178 void dropMsg( ObjId mid );
00179
00183 void clearBinding( BindIndex b );
00184
00189 void addMsgAndFunc( ObjId mid, FuncId fid, BindIndex bindIndex );
00190
00196 const vector< MsgFuncBinding >* getMsgAndFunc( BindIndex b ) const;
00197
00202 bool hasMsgs( BindIndex b ) const;
00203
00207 void showFields() const;
00208
00212 void showMsg() const;
00213
00217 void digestMessages();
00218
00223 void putTargetsInDigest(
00224 unsigned int srcNum, const MsgFuncBinding& mfb,
00225 const FuncOrder& fo,
00226 vector< vector< bool > >& targetNodes
00227 );
00231 void putOffNodeTargetsInDigest(
00232 unsigned int srcNum, vector< vector< bool > >& targetNodes );
00233
00237 const Cinfo* cinfo() const;
00238
00246 static void destroyElementTree( const vector< Id >& tree );
00247
00252 void markAsDoomed();
00253 bool isDoomed() const;
00254
00259 void markRewired();
00260
00264 void printMsgDigest( unsigned int srcIndex, unsigned int dataIndex ) const;
00265
00270 void dropAllMsgsFromSrc( Id src );
00272
00274
00280 const vector< MsgDigest >& msgDigest( unsigned int index );
00281
00286 unsigned int findBinding( MsgFuncBinding b ) const;
00287
00291 const vector< ObjId >& msgIn() const;
00292
00298 ObjId findCaller( FuncId fid ) const;
00299
00304 unsigned int getInputMsgs( vector< ObjId >& caller, FuncId fid)
00305 const;
00306
00311 unsigned int getNeighbors( vector< Id >& ret, const Finfo* finfo )
00312 const;
00313
00320 unsigned int getFieldsOfOutgoingMsg(
00321 ObjId mid, vector< pair< BindIndex, FuncId > >& ret ) const;
00322
00330 unsigned int getMsgTargetAndFunctions( DataId srcDataId,
00331 const SrcFinfo* finfo ,
00332 vector< ObjId >& tgt,
00333 vector< string >& func
00334 ) const;
00335
00343 unsigned int getMsgSourceAndSender( FuncId fid,
00344 vector< ObjId >& src,
00345 vector< string >& sender
00346 ) const;
00347
00352 vector< ObjId > getMsgTargets( DataId srcDataId,
00353 const SrcFinfo* finfo ) const;
00354
00359 void clearAllMsgs();
00360
00369 virtual void zombieSwap( const Cinfo* zCinfo );
00370
00372 void replaceCinfo( const Cinfo* newCinfo );
00373
00374 private:
00379 unsigned int getOutputs( vector< Id >& ret, const SrcFinfo* finfo )
00380 const;
00381
00386 unsigned int getInputs( vector< Id >& ret, const DestFinfo* finfo )
00387 const;
00388
00389 string name_;
00390
00391 Id id_;
00392
00396 const Cinfo* cinfo_;
00397
00402 vector< ObjId > m_;
00403
00413 vector< vector < MsgFuncBinding > > msgBinding_;
00414
00427 vector< vector < MsgDigest > > msgDigest_;
00428
00430 int tick_;
00431
00433 bool isRewired_;
00434
00436 bool isDoomed_;
00437 };
00438
00439 #endif // _ELEMENT_H