te::v8::common::JsContextManager Class Reference

A singleton for managing JavaScript contexts. More...

#include <JsContextManager.h>

Inheritance diagram for te::v8::common::JsContextManager:
te::common::Singleton< JsContextManager >

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...
 
JsContextgetCtx (const std::string &id) const
 It returns the context identified by id. More...
 

Static Public Member Functions

static JsContextManagergetInstance ()
 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 >
 

Detailed Description

A singleton for managing JavaScript contexts.

See also
JVM

Definition at line 52 of file JsContextManager.h.

Constructor & Destructor Documentation

te::v8::common::JsContextManager::JsContextManager ( )
private

Singleton constructor.

Definition at line 53 of file JsContextManager.cpp.

te::v8::common::JsContextManager::~JsContextManager ( )
private

Singleton destructor.

Definition at line 57 of file JsContextManager.cpp.

References clear().

Member Function Documentation

void te::v8::common::JsContextManager::add ( const std::string &  id,
JsContext ctx 
)

It adds a new context to be managed.

Parameters
idThe context id.
ctxThe context to be managed. The singleton will take the JVM ownership.
Exceptions
ExceptionIt 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.

Parameters
idThe context identifier.
Returns
A pointer to a context managed by this singleton or NULL if none is found.

Definition at line 34 of file JsContextManager.cpp.

References te::common::GetPValue(), and m_ctxMap.

Referenced by add().

static JsContextManager & te::common::Singleton< JsContextManager >::getInstance ( )
staticinherited

It returns a reference to the singleton instance.

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().

Friends And Related Function Documentation

friend class te::common::Singleton< JsContextManager >
friend

Definition at line 54 of file JsContextManager.h.

Member Data Documentation

std::map<std::string, JsContext*> te::v8::common::JsContextManager::m_ctxMap
private

A map from (JsContext id) to (JsContext instance).

Definition at line 90 of file JsContextManager.h.

Referenced by add(), clear(), and getCtx().


The documentation for this class was generated from the following files: