Mercurial > hg > Database > jungle-sharp
diff src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/store/impl/logger/LoggingNode.cs @ 17:01a08cf4b2d9
Liq Files
author | Kazuma |
---|---|
date | Mon, 07 Nov 2016 01:05:24 +0900 |
parents | abe0c247f5a5 |
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-main/store/impl/logger/LoggingNode.cs Mon Nov 07 01:05:24 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; + } + +}