Mercurial > hg > Database > jungle-sharp
diff src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/DefaultJungle.cs @ 0:dec15de2c6ff
first commit
author | Kazuma |
---|---|
date | Tue, 21 Jun 2016 17:11:12 +0900 |
parents | |
children | 4d08270a61c8 02b2ab7bffe6 |
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/DefaultJungle.cs Tue Jun 21 17:11:12 2016 +0900 @@ -0,0 +1,101 @@ +using System.Collections; +using System.Collections.Generic; +using System; +using UnityEngine; + +public class DefaultJungle : Jungle { + private Journal journal; + private Dictionary<string, JungleTree> trees; + private string uuid; + private TreeEditor editor; + + public void Start(){ + DefaultJungle j = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); + JungleTree t = j.createNewTree ("fuga"); + + JungleTreeEditor e1 = t.getTreeEditor (); + + DefaultNodePath root = new DefaultNodePath (); + Either<Error, JungleTreeEditor> either = e1.addNewChildAt (root, 0); + e1 = either.b(); + either = e1.addNewChildAt (root.add (0), 0); + e1 = either.b (); + e1.success (); + } + + public DefaultJungle(Journal journal, string uuid, TreeEditor editor){ + this.journal = new NullJournal(); + this.trees = new Dictionary <string, JungleTree>(); + this.uuid = uuid; + this.editor = editor; + } + + + public JungleTree getTreeByName(string name) { + + JungleTree j = trees[name]; + if (j != null) { + return trees [name]; + } else { + return null; + } + } + + public JungleTree createNewTree(string name) { + ChangeList list = new InnerChangeList(uuid,name); + // Debug.Log( list.getTreeName ()); + + DefaultTreeNode root = new DefaultTreeNode (); + InterfaceTraverser traverser = new InterfaceTraverser (root, true); + TreeContext tc = new DefaultTreeContext (root, null, list, uuid, name, 0, traverser); + JungleTree newTree = new DefaultJungleTree (tc, uuid, journal.getWriter (), editor); + trees.Add (name, newTree); + // Trees.getValue => nullの時 ここはどう書けば? +// if (trees.TryGetValue (name, newTree) != null) { +// return null; +// } + return newTree; + } + + public class InnerChangeList : ChangeList { + + string uuid; + string name; + + + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + + public IEnumerator<TreeOperation> GetEnumerator() + { + return iterator (); + } + + // construct + public InnerChangeList(string _uuid, string _name) { + this.uuid = _uuid; + this.name = _name; + } + + public IEnumerator<TreeOperation> iterator() { + List<TreeOperation> nil = new List<TreeOperation>(); + return nil.iterator(); + } + + public string uuids() { + return uuid; + } + + public string getTreeName() { + return name; + } + + public TreeOperationLog getLog() { + return new DefaultTreeOperationLog(); + } + } + + +} \ No newline at end of file