paysages3d/src/definition/BaseDefinition.cpp

55 lines
922 B
C++
Raw Normal View History

#include "BaseDefinition.h"
BaseDefinition::BaseDefinition(BaseDefinition* parent):
parent(parent)
{
2013-10-30 14:39:56 +00:00
if (parent)
{
root = parent->root;
}
else
{
root = this;
}
}
BaseDefinition::~BaseDefinition()
{
QListIterator<BaseDefinition*> it(children);
while (it.hasNext())
{
delete it.next();
}
}
void BaseDefinition::addChild(BaseDefinition* child)
{
if (not children.contains(child))
{
children.append(child);
}
}
void BaseDefinition::removeChild(BaseDefinition* child)
{
children.removeOne(child);
}
void BaseDefinition::save(PackStream* pack)
{
QListIterator<BaseDefinition*> it(children);
while (it.hasNext())
{
it.next()->save(pack);
}
}
void BaseDefinition::load(PackStream* pack)
{
QListIterator<BaseDefinition*> it(children);
while (it.hasNext())
{
it.next()->load(pack);
}
}