diff Main/jungle-network/operations/NetworkTreeOperation.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children f2ea780b3e80
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Main/jungle-network/operations/NetworkTreeOperation.cs	Thu Dec 15 22:52:48 2016 +0900
@@ -0,0 +1,56 @@
+using UnityEngine;
+using System.Collections;
+
+namespace JungleDB {
+	public class NetworkTreeOperation : TreeOperation {
+
+		public NetworkNodePath Path;
+		public NetworkNodeOperation Operation;
+
+		public NetworkTreeOperation (TreeOperation tOp) {
+			this.Path = new NetworkNodePath(tOp.getNodePath());
+			this.Operation = new NetworkNodeOperation(tOp.getNodeOperation());
+		}
+
+		public NetworkTreeOperation(NodePath path, NodeOperation op) {
+			this.Path = new NetworkNodePath(path);
+			this.Operation = new NetworkNodeOperation(op);
+		}
+
+		public NetworkTreeOperation(NetworkNodePath path, NodeOperation op) {
+			this.Path = path;
+			this.Operation = new NetworkNodeOperation(op);
+		}
+
+		public NetworkTreeOperation(NodePath path, NetworkNodeOperation op) {
+			this.Path = new NetworkNodePath(path);
+			this.Operation = op;
+		}
+
+		public NetworkTreeOperation(NetworkNodePath path, NetworkNodeOperation op) {
+			this.Path = path;
+			this.Operation = op;
+		}
+
+		public NodePath getNodePath () {
+			return this.Path;
+		}
+
+		public NodeOperation getNodeOperation() {
+			Command c = this.Operation.getCommand();
+			switch(c){
+			case Command.PUT_ATTRIBUTE:
+				return new PutAttributeOperation(Operation.getKey(), Operation.getValue());
+			case Command.APPEND_CHILD:
+				return new AppendChildAtOperation(Operation.getPosition());
+			case Command.DELETE_CHILD:
+				return new DeleteChildAtOperation(Operation.getPosition());
+			case Command.DELETE_ATTRIBUTE:
+				return new DeleteAttributeOperation(Operation.getKey());
+			default:
+				break;
+			}
+			return null;
+		}
+	}
+}