view src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/TreeRepository.java @ 12:df42dca47c3e

rename and commit
author Shoshi TAMAKI
date Fri, 14 Dec 2012 21:23:23 +0900
parents a2c019a77c27
children a46ff0114a9e
line wrap: on
line source

package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl;

import java.util.concurrent.atomic.AtomicReference;

import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command;
import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Constants;

import fj.data.List;

public class TreeRepository
{
	private final AtomicReference<ChangeSetImpl> changeSet;
	
	public TreeRepository(TraverserProvider _provider)
	{
		List<Command> emptyCommands = List.nil();
		
		TraversableTreeImpl ttree = new TraversableTreeImpl(_provider);
		
		changeSet = new AtomicReference<ChangeSetImpl>(
				new ChangeSetImpl(TreeImpl.EMPTY,emptyCommands,
						Constants.DEFAULT_OWNER,Constants.DEFAULT_REVISION_START_NUMBER,null)
			);
	}
	
	public ChangeSetImpl getCurrentChangeSet()
	{
		return changeSet.get();
	}
	
	public boolean commitChangeSet(ChangeSetImpl _newChangeSet,ChangeSetImpl _currentChangeSet)
	{
		return changeSet.compareAndSet(_currentChangeSet,_newChangeSet);
	}
}