Mercurial > hg > Database > jungle-sharp
comparison Main/jungle-main/store/impl/logger/LoggingChildren.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 System.Collections; | |
2 using UnityEngine; | |
3 | |
4 namespace JungleDB { | |
5 public class LoggingChildren { | |
6 private TreeNode wrap; | |
7 private OperationLog log; | |
8 | |
9 public LoggingChildren(TreeNode _wrap,OperationLog _log) | |
10 { | |
11 wrap = _wrap; | |
12 log = _log; | |
13 } | |
14 | |
15 public int size() | |
16 { | |
17 Children children = wrap.getChildren(); | |
18 return children.size(); | |
19 } | |
20 | |
21 public Either<Error,LoggingNode> edit(NodeOperation _op) | |
22 { | |
23 Either<Error,TreeNode> either = _op.invoke(wrap); | |
24 if(either.isA()){ | |
25 return DefaultEither<Error,LoggingNode>.newA(either.a()); | |
26 } | |
27 | |
28 TreeNode newWrap = either.b(); | |
29 OperationLog newLog = log.add(_op); | |
30 LoggingNode newLoggingNode = new LoggingNode(newWrap,newLog); | |
31 return DefaultEither<Error,LoggingNode>.newB(newLoggingNode); | |
32 } | |
33 | |
34 public Either<Error,LoggingNode> addNewChildAt(int _pos) | |
35 { | |
36 Debug.Log ("in addNewChild"); | |
37 NodeOperation addNewChildAt = new AppendChildAtOperation(_pos); | |
38 return edit(addNewChildAt); | |
39 } | |
40 | |
41 public Either<Error,LoggingNode> deleteChildAt(int _pos) | |
42 { | |
43 NodeOperation deleteChildAt = new DeleteChildAtOperation(_pos); | |
44 return edit(deleteChildAt); | |
45 } | |
46 | |
47 public Either<Error,LoggingNode> at(int _pos) | |
48 { | |
49 Children children = wrap.getChildren(); | |
50 Either<Error,TreeNode> either = children.at(_pos); | |
51 if(either.isA()){ | |
52 return DefaultEither<Error,LoggingNode>.newA(either.a()); | |
53 } | |
54 | |
55 TreeNode node = either.b(); | |
56 LoggingNode logNode = new LoggingNode(node); | |
57 return DefaultEither<Error,LoggingNode>.newB(logNode); | |
58 } | |
59 | |
60 } | |
61 } |