001    package toolbus.atom.msg;
002    
003    import java.util.Stack;
004    import toolbus.State;
005    import toolbus.TBTermFactory;
006    import toolbus.atom.Atom;
007    import toolbus.exceptions.ToolBusException;
008    import toolbus.matching.MatchStore;
009    import toolbus.parsercup.PositionInformation;
010    import toolbus.process.ProcessExpression;
011    import toolbus.process.ProcessInstance;
012    import aterm.ATerm;
013    
014    /**
015     * @author paulk, Aug 3, 2002
016     */
017    public class RecMsg extends MsgAtom{
018            
019            public RecMsg(ATerm msg, TBTermFactory tbfactory, PositionInformation posInfo){
020                    super(msg, tbfactory, posInfo);
021            }
022            
023            public ProcessExpression copy(){
024                    Atom a = new RecMsg(msg, tbfactory, getPosInfo());
025                    a.copyAtomAttributes(this);
026                    return a;
027            }
028            
029            public void compile(ProcessInstance pi, Stack<String> calls, State follow) throws ToolBusException{
030                    super.compile(pi, calls, follow);
031                    
032                    registerPartners();
033            }
034            
035            public void registerPartners(){
036                    MatchStore matchStore = getToolBus().getMatchStore();
037                    matchStore.registerReceiveMessage(this);
038            }
039            
040            public void destroy(){
041                    MatchStore matchStore = getToolBus().getMatchStore();
042                    matchStore.deregisterReceiveMessage(this);
043            }
044            
045            public boolean execute(){
046                    // Communication is always initiated by the sender,
047                    // So for the receiver nothing needs to be done.
048                    return false;
049            }
050    }