summaryrefslogtreecommitdiffstats
path: root/arts/modules/common/env_item_impl.cc
blob: 6bc960d8807ba2fc981d761d6c62ee504f5f310b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "artsmodulescommon.h"
#include "debug.h"
#include "env_item_impl.h"

using namespace Arts;
using namespace std;

Environment::Item_impl::Item_impl()
	: _active(false)
{
}

Environment::Item_impl::~Item_impl()
{
	// Items can't be deleted while they are still inside a Container
	arts_assert(_active == false);
}

Environment::Container Environment::Item_impl::parent()
{
	Container p = _parent;
	return p;
}

void Environment::Item_impl::setContainer(Environment::Container container)
{
	if(container.isNull()) // remove from container
	{
		arts_return_if_fail(_active == true);

		_parent = container;
		_active = false;
	}
	else // add to container
	{
		Container p = _parent;
		arts_return_if_fail(p.isNull() && _active == false);

		_parent = container;
		_active = true;
	}
	active_changed(_active);
}

bool Environment::Item_impl::active()
{
	return _active;
}