Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5492c963eb9140696e32067bec2f85db5219ebcc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*******************************************************************************
 * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.etrice.runtime.java.modelbase;

import org.eclipse.etrice.runtime.java.messaging.AbstractMessageReceiver;
import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;

/**
 * The abstract base class for actor class interface items like ports and saps.
 * 
 * @author Henrik Rentz-Reichert
 *
 */
public abstract class InterfaceItemBase extends AbstractMessageReceiver {
	
	private IMessageReceiver ownMsgReceiver;
	private IMessageReceiver peerMsgReceiver;
	private int localId;
	private int idx;
	private Address peerAddress;

	public InterfaceItemBase (IEventReceiver actor, String name, int localId, int idx, Address ownAddress, Address peerAddress){
		super(actor, ownAddress, name);
		this.ownMsgReceiver = RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(ownAddress.threadID);
		this.peerMsgReceiver = RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(peerAddress.threadID);
		this.localId = localId;
		this.idx = idx;
		this.peerAddress = peerAddress;
		
		if (getAddress()!=null && this.ownMsgReceiver instanceof MessageService) {
			MessageService ms = (MessageService) this.ownMsgReceiver;
			// register at the own dispatcher to receive messages
			ms.getMessageDispatcher().addMessageReceiver(this);
		}
	}

	protected IMessageReceiver getMsgReceiver() {
		return ownMsgReceiver;
	}

	protected IMessageReceiver getPeerMsgReceiver() {
		return peerMsgReceiver;
	}

	public void setMsgReceiver(IMessageReceiver msgReceiver) {
		this.ownMsgReceiver = msgReceiver;
	}
	
	public IEventReceiver getActor() {
		return (IEventReceiver) getParent();
	}

	public int getLocalId() {
		return localId;
	}

	public int getIdx() {
		return idx;
	}

	protected Address getPeerAddress() {
		return peerAddress;
	}
}

Back to the top