MatchTaskServer Class Reference

Inheritance diagram for MatchTaskServer:

Inheritance graph
[legend]
Collaboration diagram for MatchTaskServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MatchTaskServer (void)
virtual void operator() (MatchStore &store)
void sendMatches (SocketInterface &socket)
void sendSequence (bool yesOrNo=true)

Private Attributes

vector< MatchInfomatches_
map< SequenceNumber, std::string > names_
bool sendSequence_

Detailed Description

Definition at line 128 of file SSAHAServer.cpp.


Constructor & Destructor Documentation

MatchTaskServer::MatchTaskServer ( void   )  [inline]

Definition at line 131 of file SSAHAServer.cpp.

00131 : sendSequence_(false) {} // SocketInterface&


Member Function Documentation

void MatchTaskServer::operator() ( MatchStore store  )  [virtual]

Implements MatchTask.

Definition at line 141 of file SSAHAServer.cpp.

References matches_, and names_.

00142 {
00143 
00144  for (MatchStore::iterator i( store.begin() ) ; i!=store.end() ; ++i )
00145  {
00146     matches_.push_back( MatchInfo( **i ) );
00147     names_.insert
00148     ( pair<SequenceNumber, string>
00149       ( (*i)->getSubjectNum(), (*i)->getSubjectName() ) );
00150  }
00151 }

void MatchTaskServer::sendMatches ( SocketInterface socket  ) 

Definition at line 153 of file SSAHAServer.cpp.

References SourceReaderIndex::extractSource(), matches_, myPID, names_, MatchHeader::numMatches, MatchHeader::numSubjectNames, pSourceReader, SocketInterface::sendChars(), sendSequence_, SocketInterface::sendString(), SocketInterface::sendStruct(), MatchInfo::subjectEnd, MatchInfo::subjectNum, MatchInfo::subjectStart, and MatchHeader::wasSuccessful.

Referenced by processQuery().

00154 {
00155 
00156   MatchHeader header;
00157   header.wasSuccessful=true; // TBD enum with more descriptive stuff
00158   header.numSubjectNames=names_.size();
00159   header.numMatches=matches_.size();
00160   cout << myPID << ": sending " << header.numMatches << " matches among "
00161        << header.numSubjectNames << " subject sequences." << endl; 
00162   
00163   socket.sendStruct(&header);
00164 
00165   char endString('\0');
00166   char* pSource;
00167 
00168   // Send the subject nums and names of all database sequences
00169   // which matched the query
00170   for ( map<SequenceNumber,std::string>::iterator i(names_.begin()); i != names_.end() ; i++  ) {
00171     cout << myPID << ": " << i->first << " " << i->second << endl;
00172     socket.sendStruct(&i->first);
00173     socket.sendString(i->second);
00174   } 
00175 
00176   // Send the match info itself
00177   for ( vector<MatchInfo>::iterator i( matches_.begin()); i != matches_.end() ; ++i ) {  
00178     
00179     socket.sendStruct((MatchInfo*)&(*i));
00180     
00181     if (sendSequence_==true) {
00182       //      cout << myPID << ": getting ready to send sequence " 
00183       //   << i->subjectNum << " " 
00184       //   << i->subjectStart << " " 
00185       //   << i->subjectEnd << endl;
00186       if(pSourceReader!=NULL) {
00187         pSourceReader->extractSource ( &pSource, i->subjectNum, i->subjectStart, i->subjectEnd );
00188         socket.sendChars( pSource, i->subjectEnd-i->subjectStart+1 );
00189         //cout << myPID << ": sent " 
00190         //   << i->subjectEnd-i->subjectStart+1 << " chars, "
00191         //   << pSource[0]
00192         //   << pSource[i->subjectEnd-i->subjectStart] << endl;
00193       } else {
00194         // send a null string if no index info is available
00195         socket.sendStruct(&endString);
00196         //      cout << myPID << ": sent null string" << endl; 
00197       }
00198     
00199     } 
00200   
00201   } 
00202 
00203 }

Here is the call graph for this function:

Here is the caller graph for this function:

void MatchTaskServer::sendSequence ( bool  yesOrNo = true  )  [inline]

Definition at line 134 of file SSAHAServer.cpp.

References sendSequence_.

Referenced by processQuery().

00134 { sendSequence_ = yesOrNo; }

Here is the caller graph for this function:


Member Data Documentation

vector<MatchInfo> MatchTaskServer::matches_ [private]

Definition at line 136 of file SSAHAServer.cpp.

Referenced by operator()(), and sendMatches().

map<SequenceNumber,std::string> MatchTaskServer::names_ [private]

Definition at line 137 of file SSAHAServer.cpp.

Referenced by operator()(), and sendMatches().

bool MatchTaskServer::sendSequence_ [private]

Definition at line 138 of file SSAHAServer.cpp.

Referenced by sendMatches(), and sendSequence().


The documentation for this class was generated from the following file:
Generated on Fri Dec 21 13:19:05 2007 for ssaha by  doxygen 1.5.2