obp . bank -> append (*(obp . obj));
obp -> bank -> append (*(obp -> obj));
int main (int argc, char ** argv){  long int cnts = 0;  long int cntc = 0;  Message_t msg;  NCode_t ncode;  map<NCode_t, obpair> obps;     // object,bank pair NCode-keyed map  ifstream msgfile;              // the message file stream  char act;                      // action enumeration  obpair obp;                    // object,bank pair pointer  //-- The KNOWN types to put in the banks  obps [M_UNIVERSAL]  = obpair (new Bank_t (M_UNIVERSAL),  new Universal_t);  obps [M_SEQUENCE]   = obpair (new Bank_t (M_SEQUENCE),   new Sequence_t);  obps [M_LIBRARY]    = obpair (new Bank_t (M_LIBRARY),    new Library_t);  obps [M_FRAGMENT]   = obpair (new Bank_t (M_FRAGMENT),   new Fragment_t);  obps [M_READ]       = obpair (new Bank_t (M_READ),       new Read_t);  obps [M_MATEPAIR]   = obpair (new Bank_t (M_MATEPAIR),   new Matepair_t);  obps [M_OVERLAP]    = obpair (new Bank_t (M_OVERLAP),    new Overlap_t);  obps [M_KMER]       = obpair (new Bank_t (M_KMER),       new Kmer_t);  obps [M_CONTIG]     = obpair (new Bank_t (M_CONTIG),     new Contig_t);  obps [M_CONTIGLINK] = obpair (new Bank_t (M_CONTIGLINK), new ContigLink_t);  obps [M_CONTIGEDGE] = obpair (new Bank_t (M_CONTIGEDGE), new ContigEdge_t);  obps [M_SCAFFOLD]   = obpair (new Bank_t (M_SCAFFOLD),   new Scaffold_t);  //-- Parse the command line arguments  ParseArgs (argc, argv);  //-- Output the current time and bank directory  cerr << "START DATE: " << Date( ) << endl;  cerr << "Bank is: " << OPT_BankName << endl;  //-- BEGIN: MAIN EXCEPTION CATCH  try {    //-- Compress RED and SEQ if option is turned on    if ( OPT_Compress )      {	((Read_t *)(obps [M_READ] . obj)) -> compress( );	((Sequence_t *)(obps [M_SEQUENCE] . obj)) -> compress( );      }    //-- Open the message file    msgfile . open (OPT_MessageName . c_str( ));    if ( !msgfile )      AMOS_THROW_IO ("Could not open message file " + OPT_MessageName);    //-- Read the message file    while ( msg . read (msgfile) )      {	//-- Increment the message counter	++ cnts;	//-- Get the message NCode and figure out the type array index	ncode = msg . getMessageCode( );	obp = obps [ncode];	if ( obp . bank == NULL )	  {	    cerr << "WARNING: Unrecognized message type "		 << Decode (ncode) << " ignored\n";	    continue;	  }	//-- Parse the message	try {	  obp . obj -> readMessage (msg);	}	catch (Exception_t & e) {	  cerr << "WARNING: " << e . what( ) << endl	       << "  could not parse fields in " << Decode (ncode)	       << " with iid:" << msg . getField (F_IID)	       << ", message ignored\n";	  continue;	}	//-- Open the bank if necessary	try {	  if ( ! obp . bank -> isOpen( ) )	    {	      if ( OPT_Create )		obp . bank -> create (OPT_BankName);	      else		obp . bank -> open (OPT_BankName);	    }	}	catch (Exception_t & e) {	  cerr << "WARNING: " << e . what( ) << endl	       << "  could not open " << Decode (ncode)	       << " bank, message ignored\n";	  continue;	}	//-- Get the message action code	if ( msg . exists (F_ACTION) )	  act = (msg . getField (F_ACTION)) [0];	else	  act = E_ADD;	//-- Perform the appropriate action on the bank	try {	  switch (act)	    {	    case E_ADD:	      //-- Append a new object to the bank	      obp . bank -> append (*(obp . obj));	      break;	    case E_DELETE:	      //-- Flag an existing object for removal from the bank	      if ( obp . obj -> getIID( ) != NULL_ID )		obp . bank -> remove (obp . obj -> getIID( ));	      else if ( ! obp . obj -> getEID( ) . empty( ) )		obp . bank -> remove (obp . obj -> getEID( ) . c_str( ));	      else		AMOS_THROW_ARGUMENT ("Cannot remove object w/o IID or EID");	      break;	    case E_REPLACE:	      //-- Replace an existing object in the bank	      if ( obp . obj -> getIID( ) != NULL_ID )		obp . bank -> replace (obp . obj -> getIID( ), *(obp . obj));	      else if ( ! obp . obj -> getEID( ) . empty( ) )		obp . bank -> replace		  (obp . obj -> getEID( ) . c_str( ), *(obp . obj));	      else		AMOS_THROW_ARGUMENT ("Cannot edit object w/o IID or EID");	      break;	    default:	      AMOS_THROW_IO ("Unrecognized action field");	    }	}	catch (IOException_t & e) {	  cerr << "WARNING: " << e . what( ) << endl	       << "  could not commit " << Decode (ncode)	       << " with iid:" << msg . getField (F_IID)	       << " to bank, message ignored\n";	  continue;	}	catch (ArgumentException_t & e) {	  cerr << "WARNING: " << e . what( ) << endl	       << "  ID conflict caused by " << Decode (ncode)	       << " with iid:" << msg . getField (F_IID)	       << ", message ignored\n";	  continue;	}	cntc ++;      }    //-- Close all the banks and free the objects    msgfile . close( );    map<NCode_t, obpair>::iterator mi;    for ( mi = obps . begin( ); mi != obps . end( ); ++ mi )      {	if ( mi -> second . bank != NULL )	  mi -> second . bank -> close( );	delete mi -> second . bank;	delete mi -> second . obj;      }  }  catch (Exception_t & e) {    //-- On error, print debugging information    cerr << "Current message: " << Decode (ncode)	 << " iid:" << msg . getField (F_IID) << endl	 << "Messages seen: " << cnts << endl	 << "Messages committed: " << cntc << endl      	 << "ERROR: -- Fatal AMOS Exception --\n" << e;    return EXIT_FAILURE;  }  //-- END: MAIN EXCEPTION CATCH      //-- Output the end time  cerr << "Messages seen: " << cnts << endl       << "Messages committed: " << cntc << endl       << "END DATE:   " << Date( ) << endl;  return EXIT_SUCCESS;}