#include "EPSG/Group.h"

EPSG::Group::Group()
{

}

bool EPSG::Group::setupCamera()
{
	std::vector<Node*>::iterator i;
	for( i = _children.begin(); i != _children.end(); ++i )
		if( (*i)->setupCamera() )
			return true;
	
	return false;
}

int EPSG::Group::setupLights()
{
	int n = 0;
	std::vector<Node*>::iterator i;
	for( i = _children.begin(); i != _children.end(); ++i )
		n += (*i)->setupLights();

	return n;
}

void EPSG::Group::render()
{
	std::vector<Node*>::iterator i;
	for( i = _children.begin(); i != _children.end(); ++i )
		(*i)->render();
}

bool EPSG::Group::addChild( Node* n )
{
	if( n == NULL )
		return false;

	if( hasChild( n ) )
		return false;

	_children.push_back( n );
	return true;
}

bool EPSG::Group::hasChild( Node* n )
{
	std::vector<Node*>::iterator i;
	for( i = _children.begin(); i != _children.end(); ++i )
		if( (*i) == n )
			return true;

	return false;
}

bool EPSG::Group::delChild( Node* n )
{
	std::vector<Node*>::iterator i;
	for( i = _children.begin(); i != _children.end(); ++i )
	{
		if( (*i) == n )
		{
			_children.erase( i );
			return true;
		}
	}
	return false;
}