// Clipboard.cpp: implementation of the CClipboard class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DiagramEng.h"
#include "Annotation.h"		// rqd. for CAnnotation objs.
#include "Block.h"			// rqd. for CBlock objs.
#include "Signal.h"			// rqd. for CConnection objs.
#include "Clipboard.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CClipboard::CClipboard()
{
	// Do nothing for now
}

CClipboard::~CClipboard()
{
	// Delete annotation list
	DeleteAnnotationList();

	// Delete block list
	DeleteBlockList();

	// Delete connection list
	DeleteConnectionList();
}

list<CAnnotation*> &CClipboard::GetAnnotationList()
{
	return m_lstAnnotation;
}

list<CBlock*> &CClipboard::GetBlockList()
{
	return m_lstBlock;
}

list<CConnection*> &CClipboard::GetConnectionList()
{
	// Return the connection list by reference
	return m_lstConnection;
}

void CClipboard::DeleteAnnotationList()
{
	list<CAnnotation*>::iterator it_an;

	// Delete annotation list
	for(it_an = m_lstAnnotation.begin(); it_an != m_lstAnnotation.end(); it_an++)
	{
		delete (*it_an);	// delete what it_an is pointing to: i.e. deref the it_an ptr and delete the ptr-to-CAnnotation.
	}
	m_lstAnnotation.clear();
}

void CClipboard::DeleteBlockList()
{
	list<CBlock*>::iterator it_blk;

	// Delete block list
	for(it_blk = m_lstBlock.begin(); it_blk != m_lstBlock.end(); it_blk++)
	{
		delete (*it_blk);	// delete what it_blk is pointing to: i.e. deref the it_blk ptr and delete the ptr-to-CBlock.
	}
	m_lstBlock.clear();
}

void CClipboard::DeleteConnectionList()
{
	list<CConnection*>::iterator it_con;

	// Delete connection list
	for(it_con = m_lstConnection.begin(); it_con != m_lstConnection.end(); it_con++)
	{
		delete (*it_con);	// delete what it_conn is pointing to: i.e. deref the it_conn ptr and delete the ptr-to-CConnection.
	}
	m_lstConnection.clear();
}
