src/terralib/vm/lua/Plugin.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled
5  applications.
6 
7  TerraLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License,
10  or (at your option) any later version.
11 
12  TerraLib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with TerraLib. See COPYING. If not, write to
19  TerraLib Team at <terralib-team@terralib.org>.
20  */
21 
22 /*!
23  \file terralib/vm/lua/Plugin.cpp
24 
25  \brief Add a plugin interface for dynamic loading of Lua Virtual Machine for
26  TerraLib.
27 
28  \author Gilberto Ribeiro de Queiroz
29  */
30 
31 // TerraLib
32 #include "../../Defines.h"
33 #include "../../core/plugin/CppPlugin.h"
34 #include "../core/VirtualMachineManager.h"
35 #include "VirtualMachine.h"
36 
37 // STL
38 #include <memory>
39 
40 namespace te
41 {
42  namespace vm
43  {
44  namespace lua
45  {
47 
49  {
50  if(m_initialized)
51  return;
52 
54  "lua", std::unique_ptr<te::vm::core::VirtualMachine>(
56 
57  m_initialized = true;
58  }
59 
61  {
62  if(!m_initialized)
63  return;
64 
66 
67  m_initialized = false;
68  }
69 
70  TERRALIB_CPP_PLUGIN_END(te::vm::lua::Plugin)
71  }
72  }
73 }
void insert(const std::string &id, std::unique_ptr< VirtualMachine > vm)
It adds a new VM to be managed.
#define TERRALIB_CPP_PLUGIN_END(plugin_class_name)
void erase(const std::string &id)
It removes a given virtual machine.
URI C++ Library.
Definition: Attributes.h:37
#define TERRALIB_CPP_PLUGIN_STARTUP
static VirtualMachineManager & instance()
Return a reference to the singleton.
Implementation of a virtual machine for the Lua Programming Language.
TERRALIB_CPP_PLUGIN_BEGIN(Plugin) TERRALIB_CPP_PLUGIN_STARTUP