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