view src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/store/impl/logger/LoggingNode.cs @ 10:abe0c247f5a5

Add Network module. but, unComplete NetworkDefaultJungleTreeEditor.cs
author Kazuma Takeda <kazuma-arashi@hotmail.co.jp>
date Sun, 23 Oct 2016 07:40:50 +0900
parents
children
line wrap: on
line source

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;
	}

}