Mercurial > hg > Database > jungle-sharp
comparison src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/DefaultJungle.cs @ 17:01a08cf4b2d9
Liq Files
author | Kazuma |
---|---|
date | Mon, 07 Nov 2016 01:05:24 +0900 |
parents | abe0c247f5a5 |
children |
comparison
equal
deleted
inserted
replaced
16:8f1ce942abfc | 17:01a08cf4b2d9 |
---|---|
1 using System.Collections; | |
2 using System.Collections.Generic; | |
3 using System; | |
4 using UnityEngine; | |
5 | |
6 public class DefaultJungle : Jungle { | |
7 private Journal journal; | |
8 private TreeMap <string, JungleTree> trees; | |
9 private string uuid; | |
10 private TreeEditor editor; | |
11 | |
12 public void Start(){ | |
13 DefaultJungle j = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); | |
14 JungleTree t = j.createNewTree ("fuga"); | |
15 | |
16 JungleTreeEditor e1 = t.getTreeEditor (); | |
17 | |
18 DefaultNodePath root = new DefaultNodePath (); | |
19 Either<Error, JungleTreeEditor> either = e1.addNewChildAt (root, 0); | |
20 e1 = either.b(); | |
21 either = e1.addNewChildAt (root.add (0), 0); | |
22 e1 = either.b (); | |
23 e1.success (); | |
24 } | |
25 | |
26 public DefaultJungle(Journal journal, string uuid, TreeEditor editor){ | |
27 this.journal = new NullJournal(); | |
28 this.trees = new TreeMap <string, JungleTree>(); | |
29 this.uuid = uuid; | |
30 this.editor = editor; | |
31 } | |
32 | |
33 public JungleTree getTreeByName(string name) { | |
34 | |
35 JungleTree jungle_tree = trees.get(name); | |
36 if (jungle_tree != null) { | |
37 return jungle_tree; | |
38 } else { | |
39 Debug.Log ("そのTreeは無いようですね。"); | |
40 return null; | |
41 } | |
42 } | |
43 | |
44 public JungleTree createNewTree(string name) { | |
45 ChangeList list = new InnerChangeList(uuid,name); | |
46 DefaultTreeNode root = new DefaultTreeNode (); | |
47 InterfaceTraverser traverser = new InterfaceTraverser (root, true); | |
48 TreeContext tc = new DefaultTreeContext (root, null, list, uuid, name, 0, traverser); | |
49 JungleTree newTree = new DefaultJungleTree (tc, uuid, journal.getWriter (), editor); | |
50 if (newTree != null) { | |
51 trees = trees.put (name, newTree); | |
52 } else { | |
53 Debug.Log ("こんばんは、nullです。"); | |
54 } | |
55 return newTree; | |
56 } | |
57 | |
58 public class InnerChangeList : ChangeList { | |
59 | |
60 string uuid; | |
61 string name; | |
62 | |
63 | |
64 IEnumerator IEnumerable.GetEnumerator() | |
65 { | |
66 return this.GetEnumerator(); | |
67 } | |
68 | |
69 public IEnumerator<TreeOperation> GetEnumerator() | |
70 { | |
71 return iterator (); | |
72 } | |
73 | |
74 // construct | |
75 public InnerChangeList(string _uuid, string _name) { | |
76 this.uuid = _uuid; | |
77 this.name = _name; | |
78 } | |
79 | |
80 public IEnumerator<TreeOperation> iterator() { | |
81 List<TreeOperation> nil = new List<TreeOperation>(); | |
82 return nil.iterator(); | |
83 } | |
84 | |
85 public string uuids() { | |
86 return uuid; | |
87 } | |
88 | |
89 public string getTreeName() { | |
90 return name; | |
91 } | |
92 | |
93 public TreeOperationLog getLog() { | |
94 return new DefaultTreeOperationLog(); | |
95 } | |
96 } | |
97 | |
98 | |
99 } |