view Main/jungle-network/operations/NetworkTreeOperationLog.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children f2ea780b3e80
line wrap: on
line source

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

namespace JungleDB {
	public class NetworkTreeOperationLog : TreeOperationLog {

		public LinkedList<NetworkTreeOperation> list;
		public int Size;
		public string Uuid;
		public string TreeName;
		public long TimeStamp;


		public NetworkTreeOperationLog () {
			list = new LinkedList<NetworkTreeOperation>();
			this.Size = 0;
			this.TreeName = "";
			this.TimeStamp = DateTime.Now.ToBinary();
		}

		public NetworkTreeOperationLog(string uid, string name, IEnumerable<TreeOperation> _list)  {
			this.list = new LinkedList<NetworkTreeOperation>();
			this.Uuid = uid;
			this.Size = 0;
			this.TreeName = name;
			this.TimeStamp = DateTime.Now.ToBinary();
			foreach(var op in _list) {
				NetworkTreeOperation nOp = new NetworkTreeOperation(op);
				this.list.AddLast(nOp);
			}
			this.Size = this.list.Count;
		}

		public NetworkTreeOperationLog (string uid, string name, IEnumerable<TreeOperation> _list, long timestamp) {
			this.Uuid = uid;
			this.TreeName = name;
			this.list = new LinkedList<NetworkTreeOperation>();
			this.Size = 0;
			this.TimeStamp = timestamp;
			foreach(var op in _list) {
				NetworkTreeOperation nOp = new NetworkTreeOperation(op);
				this.list.AddLast(nOp);
			}
			this.Size = this.list.Count;
		}

		public NetworkTreeOperationLog (IEnumerable<TreeOperation> _list) {
			this.Uuid = "";
			this.TreeName = "";
			this.list = new LinkedList<NetworkTreeOperation>();
			this.Size = 0;
			this.TimeStamp = DateTime.Now.ToBinary();
			foreach(var op in _list) {
				NetworkTreeOperation nOp = new NetworkTreeOperation(op);
				this.list.AddLast(nOp);
			}
			this.Size = this.list.Count;
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return this.GetEnumerator();
		}

		public IEnumerator<TreeOperation> GetEnumerator()
		{
			foreach(NetworkTreeOperation l in list){
				yield return l;
			}
		}


		public TreeOperationLog add (NodePath path, NodeOperation op) {
			NetworkTreeOperation nOp = new NetworkTreeOperation(path, op);
			this.list.AddLast(nOp);
			this.Size = list.Count;
			return this;
		}

		public TreeOperationLog append (TreeOperationLog log) {
			foreach(TreeOperation o in log) {
				NetworkTreeOperation op = new NetworkTreeOperation(o);
				this.list.AddLast(op);
			}
			this.Size = list.Count;
			return this;
		}

		public int length () {
			return this.list.Count;
		}

		public string getUuid() {
			return Uuid;
		}

		public string getTreeName () {
			return TreeName;
		}

		public long getTimeStamp () {
			return TimeStamp;
		}

		public void setTimeStamp (long timestamp) {
			this.TimeStamp = timestamp;
		}
	}
}