diff Main/jungle-main/store/impl/logger/LoggingNode.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children 9588ad364fdd
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Main/jungle-main/store/impl/logger/LoggingNode.cs	Thu Dec 15 22:52:48 2016 +0900
@@ -0,0 +1,59 @@
+using UnityEngine;
+using System.Collections;
+
+namespace JungleDB {
+	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;
+		}
+	}
+}