All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Module.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 Module.cpp
22 
23  \brief The TerraLib Xerces module is a plugin.
24 */
25 
26 // TerraLib
27 #include "../common/Logger.h"
28 #include "../common/Translator.h"
29 
30 #include "Exception.h"
31 #include "Module.h"
32 #include "ReaderFactory.h"
33 
34 // Xerces-C++
35 #include <xercesc/util/PlatformUtils.hpp>
36 #include <xercesc/util/XMLString.hpp>
37 
39 
41  : te::plugin::CppPlugin(pInfo)
42 {
43 }
44 
46 {
47 }
48 
50 {
51  if(m_initialized)
52  return;
53 
54  try
55  {
56  xercesc::XMLPlatformUtils::Initialize();
57  }
58  catch(const xercesc::XMLException& e)
59  {
60  char* exceptMesg = xercesc::XMLString::transcode(e.getMessage());
61 
62  std::string m = TE_TR("Error during Xerces initialization. Exception messages is: ");
63  m += exceptMesg;
64 
65  xercesc::XMLString::release(&exceptMesg);
66 
67  throw te::xerces::Exception(m);
68  }
69 
70  // it initializes the reader factory based on Xerces
72 
73  TE_LOG_TRACE(TE_TR("TerraLib Xerces driver startup!"));
74 
75  m_initialized = true;
76 }
77 
79 {
80  if(!m_initialized)
81  return;
82 
83  // it finalizes the reader factory based on Xerces
85 
86  try
87  {
88  xercesc::XMLPlatformUtils::Terminate();
89  }
90  catch(const xercesc::XMLException& e)
91  {
92  char* exceptMesg = xercesc::XMLString::transcode(e.getMessage());
93 
94  std::string m = TE_TR("Error during Xerces finalization. Exception messages is: ");
95  m += exceptMesg;
96 
97  xercesc::XMLString::release(&exceptMesg);
98 
99  throw te::xerces::Exception(m);
100  }
101 
102  TE_LOG_TRACE(TE_TR("TerraLib Xerces driver shutdown!"));
103 
104  m_initialized = true;
105 }
106 
108 
109 
110 
#define TE_LOG_TRACE(msg)
Use this tag in order to log a message to a specified logger with the TRACE level.
Definition: Logger.h:136
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:345
void startup()
This method will be called by TerraLib to startup some plugin's functionality.
Definition: Module.cpp:49
void shutdown()
This method will be called by TerraLib to shutdown plugin's functionality.
Definition: Module.cpp:78
#define PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME)
This macro should be used by C++ plugins in order to declare the exportable/callable DLL function...
Definition: Config.h:57
static void initialize()
It initializes the factory: it will be registered in the abstract factory ReaderFactory.
static void finalize()
It finalizes the factory: it will be destroyed and will be unregistered from the abstract factory Rea...
Module(const te::plugin::PluginInfo &pInfo)
Plugin constructor.
Definition: Module.cpp:40
static bool m_initialized
Definition: Module.h:97
An exception class for the xerces module.
The TerraLib Xerces module is a plugin.
Definition: Module.h:42
The basic information about a plugin.
Definition: PluginInfo.h:61