Mercurial > hg > Database > jungle-sharp
diff Main/jungle-main/DefaultJungle.cs @ 20:1f99e150f336
fix folder and add Object Mapper.
author | Kazuma Takeda |
---|---|
date | Thu, 15 Dec 2016 22:52:48 +0900 |
parents | |
children | 9588ad364fdd |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Main/jungle-main/DefaultJungle.cs Thu Dec 15 22:52:48 2016 +0900 @@ -0,0 +1,99 @@ +using System.Collections; +using System.Collections.Generic; +using System; +using UnityEngine; + +namespace JungleDB { + public class DefaultJungle : Jungle { + private Journal journal; + private TreeMap <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.commit (); + } + + public DefaultJungle(Journal journal, string uuid, TreeEditor editor){ + this.journal = new NullJournal(); + this.trees = new TreeMap <string, JungleTree>(); + this.uuid = uuid; + this.editor = editor; + } + + public JungleTree getTreeByName(string name) { + + JungleTree jungle_tree = trees.get(name); + if (jungle_tree != null) { + return jungle_tree; + } else { + Debug.Log ("そのTreeは無いようですね。"); + return null; + } + } + + public JungleTree createNewTree(string name) { + ChangeList list = new InnerChangeList(uuid,name); + 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); + if (newTree != null) { + trees = trees.put (name, newTree); + } else { + Debug.Log ("こんばんは、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