VirtualMachineManager.h
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 applications.
5 
6  TerraLib is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License,
9  or (at your option) any later version.
10 
11  TerraLib is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with TerraLib. See COPYING. If not, write to
18  TerraLib Team at <terralib-team@terralib.org>.
19  */
20 
21 /*!
22  \file terralib/vm/core/VirtualMachineManager.h
23 
24  \brief A singleton for managing TerraLib Virtual Machines.
25 
26  \author Frederico Augusto BedĂȘ
27  \author Gilberto Ribeiro de Queiroz
28 */
29 
30 #ifndef __TERRALIB_VM_CORE_VIRTUALMACHINEMANAGER_H__
31 #define __TERRALIB_VM_CORE_VIRTUALMACHINEMANAGER_H__
32 
33 // TerraLib
34 #include "Config.h"
35 
36 // STL
37 #include <memory>
38 
39 #include <boost/function.hpp>
40 
41 namespace te
42 {
43  namespace vm
44  {
45  namespace core
46  {
47 // Forward declarations
48  class VirtualMachine;
49 
50  /*!
51  \class VirtualMachineManager
52 
53  \brief A singleton for managing TerraLib Virtual Machines.
54 
55  \sa VirtualMachine
56  */
58  {
59  public:
60 
61  /*!
62  \brief It returns the VM identified by id.
63 
64  \param id The VM identifier. Example: lua, python.
65 
66  \return A pointer to a VM managed by this singleton.
67 
68  \exception te::OutOfRangeException If there is no virtual machine registered with the given id.
69  */
70  VirtualMachine* get(const std::string& id) const;
71 
72  /*!
73  \brief It adds a new VM to be managed.
74 
75  \param id The VM id.
76  \param lvm The VM to be managed. The singleton will take the VM ownership.
77 
78  \exception te::InvalidArgumentException It throws an exception if a VM with the same ID already exists.
79  */
80  void insert(const std::string& id, std::unique_ptr<VirtualMachine> vm);
81 
82  /*! \brief It releases all VM. */
83  void clear();
84 
85  /*!
86  \brief It removes a given virtual machine.
87 
88  \param id The VM id.
89 
90  \exception te::OutOfRangeException If there is no virtual machine registered with the given id.
91  */
92  void erase(const std::string& id);
93 
94  //! Return a reference to the singleton.
95  static VirtualMachineManager& instance();
96 
97  private:
98 
99  /*! \brief Singleton constructor. */
101 
102  /*! \brief Singleton destructor. */
104 
105 // No copy allowed
107  VirtualMachineManager& operator=(const VirtualMachineManager&);
108 
109  private:
110 
111  struct Impl;
112  Impl* m_pimpl;
113  };
114 
115  } // end namespace core
116  } // end namespace vm
117 } // end namespace te
118 
119 #endif // __TERRALIB_VM_CORE_VIRTUALMACHINEMANAGER_H__
A singleton for managing TerraLib Virtual Machines.
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
URI C++ Library.
#define TEVMEXPORT
Definition: Config.h:40
Configuration flags for TerraLib VM Library.