comparison 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
comparison
equal deleted inserted replaced
19:0865819106cf 20:1f99e150f336
1 using UnityEngine;
2 using System.Collections;
3
4 namespace JungleDB {
5 public class LoggingNode {
6 private TreeNode wrap;
7 private OperationLog log;
8
9 public LoggingNode(TreeNode _wrap)
10 : this(_wrap,new DefaultOperationLog())
11 {
12 }
13
14 public LoggingNode(TreeNode _wrap,OperationLog _log)
15 {
16 wrap = _wrap;
17 log = _log;
18 }
19
20 public LoggingAttributes getAttributes()
21 {
22 return new LoggingAttributes(wrap,log);
23 }
24
25 public LoggingChildren getChildren()
26 {
27 Debug.Log ("in gtChildren");
28 return new LoggingChildren(wrap,log);
29 }
30
31
32 public OperationLog getOperationLog()
33 {
34 return log;
35 }
36
37 public Either<Error, LoggingNode> replaceNewRootNode() {
38 NodeOperation replaceRootNode = new ReplaceRootNodeOperation();
39 return edit(replaceRootNode);
40 }
41
42 public Either<Error, LoggingNode> edit(NodeOperation op){
43 Either<Error,TreeNode> either = op.invoke(wrap);
44 if(either.isA()){
45 return DefaultEither<Error, LoggingNode>.newA(either.a());
46 }
47
48 TreeNode newWrap = either.b();
49 OperationLog newLog = log.add(op);
50 LoggingNode newLoggingNode = new LoggingNode(newWrap,newLog);
51 return DefaultEither<Error, LoggingNode>.newB(newLoggingNode);
52 }
53
54 public TreeNode getWrap()
55 {
56 return wrap;
57 }
58 }
59 }