/******************************************************************* * * DESCRIPTION: class Processor * * AUTHOR: Amir Barylko & Jorge Beyoglonian * * EMAIL: mailto://amir@dc.uba.ar * mailto://jbeyoglo@dc.uba.ar * * DATE: 27/6/1998 * *******************************************************************/ /** include files **/ #include "process.h" // header #include "model.h" // class Model #include "msgadm.h" // SingleMsgAdm /** public data **/ const ProcId Processor::InvalidId( -1 ) ; /** public functions **/ /******************************************************************* * Function Name: Processor ********************************************************************/ Processor::Processor( Model *m ) : mdl( m ) , ident( InvalidId ) , procType("PROCESSOR") { MASSERT( m ); } /******************************************************************* * Function Name: receive * Description: just throw exception ********************************************************************/ Processor &Processor::receive( const InitMessage & ) { InvalidMessageException e ; e.addText( "The abstract base class Processor cannot receive InitMessage!" ) ; MTHROW( e ) ; return *this ; } /******************************************************************* * Function Name: receive * Description: just throw exception ********************************************************************/ Processor &Processor::receive( const InternalMessage & ) { InvalidMessageException e ; e.addText( "The abstract base class Processor cannot receive InternalMessage!" ) ; MTHROW( e ) ; } /******************************************************************* * Function Name: receive * Description: just throw exception ********************************************************************/ Processor &Processor::receive( const OutputMessage & ) { InvalidMessageException e ; e.addText( "The abstract base class Processor cannot receive OutputMessage!" ) ; MTHROW( e ) ; } /******************************************************************* * Function Name: receive * Description: just throw exception ********************************************************************/ Processor &Processor::receive( const ExternalMessage & msg) { ExternalMessage *extMsg = dynamic_cast< ExternalMessage*> (msg.clone()) ; externalMsgs.add(extMsg) ; // cout << "Processor: One message is added to the message bag of " << this->description() // << " at: " << msg.time() << " (" << msg.value() << " ) from " << msg.senderModelId() << endl; return *this; /* Rami: external messages are to be inserted in the bag for all processors InvalidMessageException e ; e.addText( "The abstract base class Processor cannot receive ExternalMessage!" ) ; MTHROW( e ) ; */ } Processor &Processor::receive(const CollectMessage &) { InvalidMessageException e ; e.addText( "The abstract base class Processor cannot receive CollectMessage!" ) ; MTHROW( e ) ; } /******************************************************************* * Function Name: receive * Description: just throw exception ********************************************************************/ Processor &Processor::receive( const DoneMessage & ) { InvalidMessageException e ; e.addText( "The abstract base class Processor cannot receive DoneMessage!" ) ; MTHROW( e ) ; } /******************************************************************* * Method: sendOutput ********************************************************************/ Processor &Processor::sendOutput( const Time &time, const Port &port, const Value &value ) { SingleMsgAdm::Instance().send( OutputMessage( time, id(), port, value ), model().parentId() ) ; return *this; } Processor::~Processor() { delete mdl; } /******************************************************************* * Function Name: description ********************************************************************/ const string Processor::description() const { return mdl->description(); }