summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/ContextManager.cpp
blob: 56ae10fff1a2929d6d23f56193e262cd0236d0a8 (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
/*
 * Context.cpp
 *
 *  Created on: Dec 7, 2012
 *      Author: attero
 */

#include "ContextManager.h"

ContextManager::ContextManager() {
	contexts["global"] = new Context("global");
	index = 0;
}

ContextManager::~ContextManager() {
}

Context * ContextManager::create_new_context()
{
	Context * context = new Context("Zdzislaw" + to_string(index));
	index++;
	contexts[context->name] = context;
	return context;
}

Context * ContextManager::get_context(std::string name)
{
	return contexts[name];
}

Context * ContextManager::context(std::string name)
{
	if(contexts.count(name) != 0) return contexts[name];
	else return nullptr;
}

void ContextManager::destroy_context(std::string name)
{
	auto iter = contexts.find(name);
	if(iter != contexts.end())
	{
		delete (*iter);
		contexts.erase(iter);
	}
}