58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
![]() |
/*
|
||
|
* Context.cpp
|
||
|
*
|
||
|
* Created on: Dec 7, 2012
|
||
|
* Author: attero
|
||
|
*/
|
||
|
|
||
|
#include "Context.h"
|
||
|
|
||
|
Context::Context() {
|
||
|
// TODO Auto-generated constructor stub
|
||
|
index = 0;
|
||
|
}
|
||
|
|
||
|
Context::~Context() {
|
||
|
// TODO Auto-generated destructor stub
|
||
|
}
|
||
|
|
||
|
ObjectIndex Context::add_to_store(SenchaObject & object)
|
||
|
{
|
||
|
index++;
|
||
|
object_store[index] = object;
|
||
|
|
||
|
return index;
|
||
|
}
|
||
|
|
||
|
SenchaObject Context::get_from_store(ObjectIndex index)
|
||
|
{
|
||
|
return object_store[index];
|
||
|
}
|
||
|
|
||
|
void Context::add(std::string name, SenchaObject object)
|
||
|
{
|
||
|
interpreter_context[name] = add_to_store(object);
|
||
|
}
|
||
|
|
||
|
void Context::set(std::string name, SenchaObject object)
|
||
|
{
|
||
|
object_store[interpreter_context[name]] = object;
|
||
|
}
|
||
|
|
||
|
SenchaObject Context::get(std::string name)
|
||
|
{
|
||
|
return get_from_store(interpreter_context[name]);
|
||
|
}
|
||
|
|
||
|
std::string Context::debug() {
|
||
|
std::string debug_note = "";
|
||
|
|
||
|
for( auto iter = this->interpreter_context.begin(); iter != this->interpreter_context.end(); iter++)
|
||
|
{
|
||
|
debug_note += "Context: " + to_string(index) + ": " + (*iter).first + " " + object_store[(*iter).second].repr() + "\n";
|
||
|
}
|
||
|
return debug_note;
|
||
|
|
||
|
|
||
|
}
|