All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
55  try
56  {
57  xercesc::XMLPlatformUtils::Initialize();
58  }
59  catch(const xercesc::XMLException& e)
60  {
61  char* exceptMesg = xercesc::XMLString::transcode(e.getMessage());
62 
63  std::string m = TR_XERCES("Error during Xerces initialization. Exception messages is: ");
64  m += exceptMesg;
65 
66  xercesc::XMLString::release(&exceptMesg);
67 
68  throw te::xerces::Exception(m);
69  }
70 
71  // it initializes the reader factory based on Xerces
73 
74  TE_LOG_TRACE(TR_XERCES("TerraLib Xerces driver startup!"));
75 
76  m_initialized = true;
77 }
78 
80 {
81  if(!m_initialized)
82  return;
83 
84  // it finalizes the reader factory based on Xerces
86 
87  try
88  {
89  xercesc::XMLPlatformUtils::Terminate();
90  }
91  catch(const xercesc::XMLException& e)
92  {
93  char* exceptMesg = xercesc::XMLString::transcode(e.getMessage());
94 
95  std::string m = TR_XERCES("Error during Xerces finalization. Exception messages is: ");
96  m += exceptMesg;
97 
98  xercesc::XMLString::release(&exceptMesg);
99 
100  throw te::xerces::Exception(m);
101  }
102 
103  TE_LOG_TRACE(TR_XERCES("TerraLib Xerces driver shutdown!"));
104 
105  m_initialized = true;
106 }
107 
109 
110 
111 
The basic information about a plugin.
Definition: PluginInfo.h:61
static void initialize()
It initializes the factory: it will be registered in the abstract factory ReaderFactory.
An exception class for the xerces module.
#define TE_XERCES_TEXT_DOMAIN
It contains the name of the text domain used in the translation of messages in TerraLib Xerces module...
Definition: Config.h:65
#define TE_LOG_TRACE(msg)
Use this tag in order to log a message to a specified logger with the TRACE level.
Definition: Config.h:418
#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 finalize()
It finalizes the factory: it will be destroyed and will be unregistered from the abstract factory Rea...
#define TE_ADD_TEXT_DOMAIN(domain, domaindir, codeset)
It adds the given text domain located at domain-dir with the given codeset to the multilingual system...
Definition: Config.h:118
Module(const te::plugin::PluginInfo &pInfo)
Plugin constructor.
Definition: Module.cpp:40
void shutdown()
This method will be called by TerraLib to shutdown plugin&#39;s functionality.
Definition: Module.cpp:79
#define TE_XERCES_TEXT_DOMAIN_DIR
It contains the translation catalog directory.
Definition: Config.h:72
void startup()
This method will be called by TerraLib to startup some plugin&#39;s functionality.
Definition: Module.cpp:49
static bool m_initialized
Definition: Module.h:97
The TerraLib Xerces module is a plugin.
Definition: Module.h:42
#define TR_XERCES(message)
It marks a string in order to get translated. This is a special mark used in the Xerces module of Ter...
Definition: Config.h:79