001 package toolbus.communication; 002 003 import aterm.ATerm; 004 005 /** 006 * DataHandlers proces the data and supply the data for ioHandlers. 007 * 008 * @author Arnold Lankamp 009 */ 010 public interface IDataHandler{ 011 012 /** 013 * Associates an ioHandler with the data handler. Every data handler needs one to operate and it 014 * must NOT be changed during it's operation. 015 * 016 * @param ioHandler 017 * The I/O handler we need to associate with the data handler. 018 */ 019 void setIOHandler(IIOHandler ioHandler); 020 021 /** 022 * Forwards a term to the associated ioHandler. 023 * 024 * @param operation 025 * The operation associated with the term we need to send. 026 * @param aTerm 027 * The term that needs to be transmitted. 028 */ 029 void send(byte operation, ATerm aTerm); 030 031 /** 032 * Receives a term from the associated ioHandler. 033 * 034 * @param operation 035 * The operation associate with the term we received. 036 * @param aTerm 037 * The term that was received. 038 */ 039 void receive(byte operation, ATerm aTerm); 040 041 /** 042 * Requests the termination of this dataHandler. 043 */ 044 void terminate(); 045 046 /** 047 * Shuts down this dataHandler. IMPORTANT: this method may only be called by the associated 048 * ioHandler. Manual invokation will lead to undefined behaviour. 049 */ 050 void shutDown(); 051 052 /** 053 * Notifies the data handler that an exception has occured so it can take the necessary steps. 054 */ 055 void exceptionOccured(); 056 }