using UnityEngine; public class LoggingAttributes { private TreeNode wrap; private OperationLog log; public LoggingAttributes(TreeNode _wrap,OperationLog _log) { wrap = _wrap; log = _log; } public byte[] get(string _key) { TreeNodeAttributes attributes = wrap.getAttributes(); return attributes.get(_key); } private Either edit(NodeOperation _op) { Either either = _op.invoke(wrap); if(either.isA()){ Debug.Log ("faild put"); return DefaultEither.newA(either.a()); } TreeNode newNode = either.b(); OperationLog newLog = log.add(_op); LoggingNode newLogNode = new LoggingNode(newNode,newLog); return DefaultEither.newB(newLogNode); } public Either delete(string _key) { DeleteAttributeOperation deleteAttribute = new DeleteAttributeOperation(_key); return edit(deleteAttribute); } public Either put(string _key, byte[] _value) { PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value); return edit(putAttribute); } }