Mercurial > hg > Database > jungle-sharp
changeset 29:f7616084d3ab
Continue to put on the created path.
author | Kazuma Takeda |
---|---|
date | Wed, 18 Jan 2017 21:02:24 +0900 |
parents | 9588ad364fdd |
children | 236a58985e22 |
files | Main/jungle-main/JungleTreeEditor.cs Main/jungle-main/core/MultiAttributes.cs Main/jungle-main/core/MultiAttributes.cs.meta Main/jungle-main/store/impl/TreeNodeAttributes.cs Main/jungle-main/store/operations/NodeOperation.cs Main/jungle-main/store/transformer/PutAttribute.cs Main/jungle-main/transaction/DefaultJungleTreeEditor.cs Main/jungle-network/transaction/NetworkDefaultJungleTreeEditor.cs README.md |
diffstat | 9 files changed, 72 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Main/jungle-main/JungleTreeEditor.cs Wed Jan 18 19:53:29 2017 +0900 +++ b/Main/jungle-main/JungleTreeEditor.cs Wed Jan 18 21:02:24 2017 +0900 @@ -4,7 +4,9 @@ Either<Error,JungleTreeEditor> addNewChildAt(NodePath path,int pos); Either<Error,JungleTreeEditor> deleteChildAt(NodePath path,int pos); Either<Error,JungleTreeEditor> putAttribute(NodePath path,string key, byte[] value); + Either<Error,JungleTreeEditor> putAttribute(string key, byte[] value); // add Method put Attribute (path, T?); + // Either<Error, JungleTreeEditor> putAttribute<T>(NodePath path, string Key, MultiAttributes<T> value); Either<Error,JungleTreeEditor> deleteAttribute(NodePath path,string key); Either<Error, JungleTreeEditor> replaceNewRootNode(); Either<Error,JungleTreeEditor> edit(NodePath path, NodeEditor editor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Main/jungle-main/core/MultiAttributes.cs Wed Jan 18 21:02:24 2017 +0900 @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace JungleDB { + public class MultiAttributes<T> { + private T attribute; + public T Attribute { + set { this.attribute = value; } + get { return this.attribute; } + } + + public MultiAttributes (T value) { + this.Attribute = value; + } + + public string getString () { + return attribute.ToString (); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Main/jungle-main/core/MultiAttributes.cs.meta Wed Jan 18 21:02:24 2017 +0900 @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5986906e4cd3448a7bcde454a46cab69 +timeCreated: 1484737113 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant:
--- a/Main/jungle-main/store/impl/TreeNodeAttributes.cs Wed Jan 18 19:53:29 2017 +0900 +++ b/Main/jungle-main/store/impl/TreeNodeAttributes.cs Wed Jan 18 21:02:24 2017 +0900 @@ -3,6 +3,7 @@ public interface TreeNodeAttributes : Attributes { Either<Error, TreeNode> delete(string key); Either<Error, TreeNode> put(string key, byte[] value); + // Either<Error, TreeNode> put<T> (string key, MultiAttributes<T> value); TreeMap<string, byte[]> getAttributesAsRawMap(); IEnumerator<string> getKeys(); }
--- a/Main/jungle-main/store/operations/NodeOperation.cs Wed Jan 18 19:53:29 2017 +0900 +++ b/Main/jungle-main/store/operations/NodeOperation.cs Wed Jan 18 21:02:24 2017 +0900 @@ -6,4 +6,12 @@ string getKey(); byte[] getValue(); } + + public interface NodeOperation<T> { + Command getCommand(); + Either<Error,TreeNode> invoke (TreeNode _target); + int getPosition(); + string getKey(); + MultiAttributes<T> getValue(); + } }
--- a/Main/jungle-main/store/transformer/PutAttribute.cs Wed Jan 18 19:53:29 2017 +0900 +++ b/Main/jungle-main/store/transformer/PutAttribute.cs Wed Jan 18 21:02:24 2017 +0900 @@ -35,4 +35,4 @@ return new LoggingNode(node, op); } } -} + }
--- a/Main/jungle-main/transaction/DefaultJungleTreeEditor.cs Wed Jan 18 19:53:29 2017 +0900 +++ b/Main/jungle-main/transaction/DefaultJungleTreeEditor.cs Wed Jan 18 21:02:24 2017 +0900 @@ -57,6 +57,7 @@ } public Either<Error, JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) { + prevPath = _path.add (_pos); AppendChildAt appendChildAt = new AppendChildAt (_pos); return _edit (_path, appendChildAt); } @@ -65,18 +66,30 @@ DeleteChildAt deleteChildAt = new DeleteChildAt(_pos); return _edit(_path,deleteChildAt); } - + public Either<Error, JungleTreeEditor> putAttribute(NodePath _path, string _key, byte[] _value) { PutAttribute putAttribute = new PutAttribute (_key, _value); return _edit (_path, putAttribute); } + /// <summary> + /// When use path, before create path. + /// * Problem -> copy to path from root everytime. + /// </summary> + /// <returns>The attribute.</returns> + /// <param name="_key">Key.</param> + /// <param name="_value">Value.</param> + public Either<Error, JungleTreeEditor> putAttribute(string _key, byte[] _value) { + PutAttribute putAttribute = new PutAttribute (_key, _value); + return _edit (prevPath, putAttribute); + } + public Either<Error, JungleTreeEditor> deleteAttribute(NodePath _path, string _key) { DeleteAttribute deleteAttribute = new DeleteAttribute (_key); return _edit (_path, deleteAttribute); } - public Either<Error,JungleTreeEditor> edit(NodePath _path,NodeEditor _editor) { + public Either<Error,JungleTreeEditor> edit(NodePath _path, NodeEditor _editor) { return _edit(_path,_editor); }
--- a/Main/jungle-network/transaction/NetworkDefaultJungleTreeEditor.cs Wed Jan 18 19:53:29 2017 +0900 +++ b/Main/jungle-network/transaction/NetworkDefaultJungleTreeEditor.cs Wed Jan 18 21:02:24 2017 +0900 @@ -11,6 +11,8 @@ private readonly TreeOperationLog Log; private bool ExportLog; + private NodePath prevPath; + public NetworkDefaultJungleTreeEditor(string tname, TreeNode root, TransactionManager txMan, TreeEditor edit) { this.TreeName = tname; @@ -77,8 +79,8 @@ } - public Either<Error,JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) - { + public Either<Error,JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) { + prevPath = _path.add (_pos); AppendChildAt appendChildAt = new AppendChildAt(_pos); return this.TreeEditor(_path,appendChildAt); } @@ -95,6 +97,12 @@ return this.TreeEditor(_path,putAttribute); } + public Either<Error,JungleTreeEditor> putAttribute(string _key, byte[] _value) + { + PutAttribute putAttribute = new PutAttribute(_key,_value); + return this.TreeEditor(prevPath, putAttribute); + } + public Either<Error,JungleTreeEditor> deleteAttribute(NodePath _path, string _key) { DeleteAttribute deleteAttribute = new DeleteAttribute(_key);