A singleton for managing JavaScript contexts. More...
#include <JsContextManager.h>
Public Member Functions | |
| void | add (const std::string &id, JsContext *ctx) |
| It adds a new context to be managed. More... | |
| void | clear () |
| It releases all contexts. More... | |
| JsContext * | getCtx (const std::string &id) const |
| It returns the context identified by id. More... | |
Static Public Member Functions | |
| static JsContextManager & | getInstance () |
| It returns a reference to the singleton instance. More... | |
Private Member Functions | |
| JsContextManager () | |
| Singleton constructor. More... | |
| ~JsContextManager () | |
| Singleton destructor. More... | |
Private Attributes | |
| std::map< std::string, JsContext * > | m_ctxMap |
| A map from (JsContext id) to (JsContext instance). More... | |
Friends | |
| class | te::common::Singleton< JsContextManager > |
A singleton for managing JavaScript contexts.
Definition at line 52 of file JsContextManager.h.
|
private |
Singleton constructor.
Definition at line 53 of file JsContextManager.cpp.
|
private |
| void te::v8::common::JsContextManager::add | ( | const std::string & | id, |
| JsContext * | ctx | ||
| ) |
It adds a new context to be managed.
| id | The context id. |
| ctx | The context to be managed. The singleton will take the JVM ownership. |
| Exception | It throws an exception if a context with the same ID already exists. |
Definition at line 39 of file JsContextManager.cpp.
References getCtx(), m_ctxMap, and TR_V8COMMON.
| void te::v8::common::JsContextManager::clear | ( | ) |
It releases all contexts.
Definition at line 47 of file JsContextManager.cpp.
References te::common::FreeContents(), and m_ctxMap.
Referenced by ~JsContextManager().
| te::v8::common::JsContext * te::v8::common::JsContextManager::getCtx | ( | const std::string & | id | ) | const |
It returns the context identified by id.
| id | The context identifier. |
Definition at line 34 of file JsContextManager.cpp.
References te::common::GetPValue(), and m_ctxMap.
Referenced by add().
|
staticinherited |
It returns a reference to the singleton instance.
Referenced by te::v8::plugin::PluginEngine::load(), te::v8::common::Module::Module(), and te::v8::common::Module::~Module().
|
friend |
Definition at line 54 of file JsContextManager.h.
|
private |