diff src/alice/codesegment/InputDataSegment.java @ 212:b5daccf36104 working

add Receiver state pattern
author one
date Wed, 27 Mar 2013 17:30:52 +0900
parents 96110f25adcc
children d50cddf64396
line wrap: on
line diff
--- a/src/alice/codesegment/InputDataSegment.java	Wed Mar 27 16:39:51 2013 +0900
+++ b/src/alice/codesegment/InputDataSegment.java	Wed Mar 27 17:30:52 2013 +0900
@@ -5,6 +5,7 @@
 import alice.datasegment.Command;
 import alice.datasegment.CommandType;
 import alice.datasegment.DataSegment;
+import alice.datasegment.ReceiveRemoteData;
 import alice.datasegment.Receiver;
 
 /**
@@ -54,17 +55,15 @@
 	public void take(Receiver receiver, String key, int index) {
 		DataSegment.getLocal().take(receiver, key, index, cs);
 	}
-	
-	public void flip(Command cmd) {
-		DataSegment.getLocal().flip(cmd);
-	}
 
 	public void reply(Receiver receiver, Command reply) {
 		receiver.index = reply.index;
-		receiver.val = reply.val;
 		receiver.from = reply.reverseKey;
-		receiver.obj = reply.obj;
-		receiver.setCommand(reply);
+		if (!reply.reverseKey.equals("local")) {
+			receiver.setData(new ReceiveRemoteData(reply.val));
+		} else {
+			receiver.setData(new ReceiveLocalData(reply.obj));
+		}
 		receive();
 	}