view src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-network/operations/NetworkTreeOperationLog.cs @ 17:01a08cf4b2d9

Liq Files
author Kazuma
date Mon, 07 Nov 2016 01:05:24 +0900
parents
children
line wrap: on
line source

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
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;
	}

}