#include "scenegroup.h"

SceneGroup::SceneGroup()
{

}

std::vector<GlNode*>* SceneGroup::getChildren() {
	return &children;
}

GlNode* SceneGroup::childAt(int i) {
	return children.at(i);
}

GlNode* SceneGroup::getChild(){
    // Automatically loops
    if(childIndex >= children.size() || childIndex < 0){ //just in case
        childIndex = 0;
    }
    return children.at(childIndex++);
}

bool SceneGroup::hasNext()
{
    if(childIndex >= children.size() || childIndex < 0) {
        childIndex = 0;
        return false;
    }

    return true;
}

void SceneGroup::addChild(GlNode* child){
    child->setParent(this);
    children.push_back(child);
    //children.push_back(std::shared_ptr<GlNode>(child));
}

void SceneGroup::accept(Visitor &v) {
    v.visit(*this);
}

SceneGroup* SceneGroup::getParent() {
    return _parent;
}

void SceneGroup::setParent(SceneGroup* s) {
    _parent = s;
}
