Main Page
Modules
Namespaces
Classes
Files
File List
File Members
JsContextManager.h
Go to the documentation of this file.
1
/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3
This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5
TerraLib is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation, either version 3 of the License,
8
or (at your option) any later version.
9
10
TerraLib is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public License
16
along with TerraLib. See COPYING. If not, write to
17
TerraLib Team at <terralib-team@terralib.org>.
18
*/
19
20
/*!
21
\file JsContextManager.h
22
23
\brief A singleton for managing JavaScript contexts.
24
*/
25
26
#ifndef __TERRALIB_BINDING_V8_COMMON_INTERNAL_JSCONTEXTMANAGER_H
27
#define __TERRALIB_BINDING_V8_COMMON_INTERNAL_JSCONTEXTMANAGER_H
28
29
// TerraLib
30
#include "../../../common/Singleton.h"
31
#include "
Config.h
"
32
33
// STL
34
#include <map>
35
36
namespace
te
37
{
38
namespace
v8
39
{
40
namespace
common
41
{
42
// Forward declarations
43
class
JsContext;
44
45
/*!
46
\class JsContextManager
47
48
\brief A singleton for managing JavaScript contexts.
49
50
\sa JVM
51
*/
52
class
TEV8COMMONEXPORT
JsContextManager
:
public
te::common::Singleton
<JsContextManager>
53
{
54
friend
class
te::common::Singleton
<
JsContextManager
>;
55
56
public
:
57
58
/*!
59
\brief It returns the context identified by id.
60
61
\param id The context identifier.
62
63
\return A pointer to a context managed by this singleton or NULL if none is found.
64
*/
65
JsContext
* getCtx(
const
std::string&
id
)
const
;
66
67
/*!
68
\brief It adds a new context to be managed.
69
70
\param id The context id.
71
\param ctx The context to be managed. The singleton will take the JVM ownership.
72
73
\exception Exception It throws an exception if a context with the same ID already exists.
74
*/
75
void
add(
const
std::string&
id
,
JsContext
* ctx);
76
77
/*! \brief It releases all contexts. */
78
void
clear();
79
80
private
:
81
82
/*! \brief Singleton constructor. */
83
JsContextManager
();
84
85
/*! \brief Singleton destructor. */
86
~
JsContextManager
();
87
88
private
:
89
90
std::map<std::string, JsContext*>
m_ctxMap
;
//!< A map from (JsContext id) to (JsContext instance).
91
};
92
93
}
// end namespace common
94
}
// end namespace v8
95
}
// end namespace te
96
97
#endif // __TERRALIB_BINDING_V8_COMMON_INTERNAL_JSCONTEXTMANAGER_H
te::v8::common::JsContextManager::m_ctxMap
std::map< std::string, JsContext * > m_ctxMap
A map from (JsContext id) to (JsContext instance).
Definition:
JsContextManager.h:90
te::v8::common::JsContext
A class for keeping reference to a persistent context.
Definition:
JsContext.h:54
TEV8COMMONEXPORT
#define TEV8COMMONEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition:
src/terralib/binding/v8/common/Config.h:98
te
URI C++ Library.
Definition:
Attributes.h:37
te::v8::common::JsContextManager
A singleton for managing JavaScript contexts.
Definition:
JsContextManager.h:52
Config.h
te::common::Singleton
Template support for singleton pattern.
Definition:
Singleton.h:100
terralib5_src
src
terralib
binding
v8
common
JsContextManager.h
Generated on Wed Jun 6 2018 12:16:09 for TerraLib by
1.8.11