#include "Salamander.h"
#include "Geometry.h"

namespace Salamander
{

Geometry::Geometry()
{

}

Geometry::~Geometry()
{
	// Clean up memory
	while(streams_.size())
	{
		Stream* stream = streams_.begin()->second;
		streams_.erase(streams_.begin());
		delete stream;
		stream = NULL;
	}

}

bool Geometry::addStream(Stream& stream)
{
	// We cannot duplicate streams of the same type
	if(streams_[stream.typeId()])
		return false;

	streams_[stream.typeId()] = &stream;
	return true;
}

const Stream* Geometry::getStream(const UniqueId& streamId) const
{
	// Ensure the stream exists in our geometry.
	StreamIterator iterator = streams_.find(streamId);
	if(iterator == streams_.end())
		return NULL;

	return iterator->second;
}

}