// Workspace.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include "Workspace.h"
#include "BinaryData.h"
#include "SimpleQueueTemplate.h"
#include "conio.h"


int _tmain(int argc, _TCHAR* argv[])
{
//	CUTF8String::EnableMemoryPool();

	CWorkspace	test;
	CUTF8String	name;

	DWORD	tick = GetTickCount();

/*
	for(int i=0;i<10;i++)
	{
		printf("try %d\n", i);

		name.Format("Top_%d", i);
		CWorkspaceAccess	top = test.GetAccess(name);

		for(int j=0;j<100;j++)
		{
			name.Format("Sec_%d", j);
			CWorkspaceAccess	sec = top.GetAccess(name);

			for(int k=0;k<10;k++)
			{
				name.Format("The_%d", k);
				CWorkspaceAccess	the = sec.GetAccess(name);

				for(int key=0;key<10;key++)
				{
					name.Format("Key_%d", key);
					the.SetKeyStr(name, name);
				}
			}
		}
	}

	tick = GetTickCount() - tick;
	printf("%d, %f[ms]\n", tick, (double)tick / (10 * 100 * 10 * 10));
*/
/*
	tick = GetTickCount();
	CWorkspace	load;
	if(load.LoadFromXMLFile(_U16("Context.xml")))
		printf("XMLLoadError\n");

	else
		printf("LoadFromXMLFile : %d[ms]\n", GetTickCount() - tick);

	tick = GetTickCount();
	if(load.SaveToXMLFile(_U16("Context_reSave.xml")))
		printf("XMLSaveError\n");

	else
		printf("SaveToXMLFile : %d[ms]\n", GetTickCount() - tick);
*/
/*
	CBinaryData	bin;
	bin.AppendLPCSTR("Test1 Test2 Test3");

	printf("Test1 : %d\n", bin.SerachMemBlock("Test1", 5));
	printf("Test2 : %d\n", bin.SerachMemBlock("Test2", 5));
	printf("Test3 : %d\n", bin.SerachMemBlock("Test3", 5));
	printf("Test4 : %d\n", bin.SerachMemBlock("3", 1));
*/

	CSimpleQueueTemplate<int>	queue;
	while(1)
	{
		printf("Type command (q=quit):");
		int	c = _getch();
		printf("%d\n", c);

		if(c == 'w')
		{
			printf("Type write val : ");
			c = _getch();
			queue.AddTail(c);
			printf("%d\n", c);
		}
		else if(c == 'r')
		{
			printf("RemoveHead val : %d\n", queue.RemoveHead());
		}

		printf("Size = %d, Read = %d, Write = %d\n", queue.m_usingSize, queue.m_readPoint, queue.m_writePoint);
		for(int i=0;i<queue.m_array.GetCount();i++)
			printf("[%d] %d\n", i, queue.m_array[i]);
		printf("\n");


		if(c == 'q')
			break;
	}

//	_getch();

	return 0;
}

