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 replaceNewRootNode() { NodeOperation replaceRootNode = new ReplaceRootNodeOperation(); return edit(replaceRootNode); } public Either edit(NodeOperation op){ Either either = op.invoke(wrap); if(either.isA()){ return DefaultEither.newA(either.a()); } TreeNode newWrap = either.b(); OperationLog newLog = log.add(op); LoggingNode newLoggingNode = new LoggingNode(newWrap,newLog); return DefaultEither.newB(newLoggingNode); } public TreeNode getWrap() { return wrap; } } }