diff src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/logger/LoggingNode.cs @ 0:dec15de2c6ff

first commit
author Kazuma
date Tue, 21 Jun 2016 17:11:12 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/logger/LoggingNode.cs	Tue Jun 21 17:11:12 2016 +0900
@@ -0,0 +1,58 @@
+using UnityEngine;
+using System.Collections;
+
+public class LoggingNode {
+	private TreeNode wrap;
+	private OperationLog log;
+
+	public LoggingNode(TreeNode _wrap)
+		: this(_wrap,new DefaultOperationLog())
+	{
+	}
+
+	public LoggingNode(TreeNode _wrap,OperationLog _log)
+	{
+		wrap = _wrap;
+		log = _log;
+	}
+
+	public LoggingAttributes getAttributes()
+	{
+		return new LoggingAttributes(wrap,log);
+	}
+
+	public LoggingChildren getChildren()
+	{
+		Debug.Log ("in gtChildren");
+		return new LoggingChildren(wrap,log);
+	}
+
+
+	public OperationLog getOperationLog()
+	{
+		return log;
+	}
+
+	public Either<Error, LoggingNode> replaceNewRootNode() {
+		NodeOperation replaceRootNode = new ReplaceRootNodeOperation();
+		return edit(replaceRootNode);
+	}
+
+	public Either<Error, LoggingNode> edit(NodeOperation op){
+		Either<Error,TreeNode> either = op.invoke(wrap);
+		if(either.isA()){
+			return DefaultEither<Error, LoggingNode>.newA(either.a());
+		}
+
+		TreeNode newWrap = either.b();
+		OperationLog newLog = log.add(op);
+		LoggingNode newLoggingNode = new LoggingNode(newWrap,newLog);
+		return DefaultEither<Error, LoggingNode>.newB(newLoggingNode);
+	}
+
+	public TreeNode getWrap()
+	{
+		return wrap;
+	}
+
+}