sencha-lang/Sencha-lang/ContextManager.h

48 lines
1014 B
C
Raw Normal View History

2012-12-08 19:59:05 +00:00
/*
* Context.h
*
* Created on: Dec 7, 2012
* Author: attero
*/
#ifndef CONTEXT_MANAGER_H_
#define CONTEXT_MANAGER_H_
2012-12-08 19:59:05 +00:00
#include <map>
#include <string>
#include <iostream>
#include <stack>
2012-12-30 21:37:10 +00:00
#include "Context.h"
2012-12-08 19:59:05 +00:00
2013-01-13 16:36:38 +00:00
/**
* ContextManager manages contexts.
*/
class ContextManager {
2012-12-08 19:59:05 +00:00
public:
ContextManager();
2013-01-13 16:36:38 +00:00
/**
* execute_function(name, arguments) executes function giving her its own execution context.
*/
SenchaObject execute_function(std::string name, std::vector<ASTExpression *> arguments);
2013-01-13 16:36:38 +00:00
//creation, destruction and basic access to contexts
2012-12-30 21:37:10 +00:00
Context * create_new_context();
void destroy_context(std::string name);
Context * context(std::string name);
2013-01-13 16:36:38 +00:00
//access to contexts using stack
Context * get_top();
void pop_context();
2013-01-13 16:36:38 +00:00
virtual ~ContextManager();
2013-01-13 16:36:38 +00:00
private:
/**
* Contexts are stored both in a stack (FILO) and in a map (indexed by names).
*/
std::stack<Context *> stack;
std::map<std::string, Context *> contexts;
unsigned int index;
2012-12-08 19:59:05 +00:00
};
#endif /* CONTEXT_MANAGER_H_ */