CppPlugin.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/core/plugin/CppPlugin.h
23 
24  \brief A base class for C++ plugins in TerraLib.
25 
26  \author Gilberto Ribeiro de Queiroz
27  \author Matheus Cavassan Zaglia
28  */
29 
30 #ifndef __TERRALIB_CORE_PLUGIN_CPPPLUGIN_H__
31 #define __TERRALIB_CORE_PLUGIN_CPPPLUGIN_H__
32 
33 // TerraLib
34 #include "AbstractPlugin.h"
35 
36 namespace te
37 {
38  namespace core
39  {
40 
41  /*!
42  \class CppPlugin
43 
44  \brief The base class for C++ plugins.
45  */
47  {
48  public:
49 
50  /*! \brief Default constructor. */
51  CppPlugin(const PluginInfo& pinfo);
52 
53  /*! \brief Virtual destructor. */
54  virtual ~CppPlugin();
55 
56  /*!
57  \brief It returns the PluginInfo of the CppPlugin
58 
59  \return The CppPlugin information
60  */
61  const PluginInfo& info() const;
62 
63  /*!
64  \brief It returns true or false if the CppPlugin was initialized
65 
66  \return The current state of the CppPlugin
67  */
68  bool initialized() const;
69 
70  protected:
71 
74  };
75 
76  /*! \brief The type of function for plugin's entry point. */
77  typedef CppPlugin* (*te_get_plugin_fnct_t)(const PluginInfo& pinfo);
78 
79  } // end namespace plugin
80 } // end namespace te
81 
82 #define TERRALIB_CPP_PLUGIN_BEGIN(plugin_class_name) \
83 class plugin_class_name : public te::core::CppPlugin \
84 { \
85  public: \
86 \
87  plugin_class_name(const te::core::PluginInfo& pinfo) \
88  : te::core::CppPlugin(pinfo) \
89  { \
90  }
91 
92 #define TERRALIB_CPP_PLUGIN_STARTUP \
93  void startup()
94 
95 #define TERRALIB_CPP_PLUGIN_SHUTDOWN \
96  void shutdown()
97 
98 #define TERRALIB_CPP_PLUGIN_END(plugin_class_name) \
99 }; \
100 TERRALIB_PLUGIN_CALL_BACK_IMPL(plugin_class_name)
101 
102 #ifdef WIN32
103  #define TERRALIB_PLUGIN_EXPORT_MACRO __declspec(dllexport)
104 #else
105  #define TERRALIB_PLUGIN_EXPORT_MACRO
106 #endif
107 
108 //! This macro should be used by C++ plugins in order to declare the exportable/callable DLL function.
109 #define TERRALIB_PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME) \
110 extern "C" TERRALIB_PLUGIN_EXPORT_MACRO te::core::CppPlugin* te_cpp_plugin_get_instance(const te::core::PluginInfo& pinfo); \
111 \
112 te::core::CppPlugin* te_cpp_plugin_get_instance(const te::core::PluginInfo& pinfo) \
113 { \
114  return new PLUGIN_CLASS_NAME(pinfo); \
115 }
116 
117 #endif // __TERRALIB_CORE_PLUGIN_CPPPLUGIN_H__
Basic information about a plugin.
Definition: PluginInfo.h:63
PluginInfo m_pinfo
Definition: CppPlugin.h:72
The base class for plugins in TerraLib.
#define TECOREEXPORT
Definition: Config.h:40
The base class for C++ plugins.
Definition: CppPlugin.h:46
URI C++ Library.
The base class for plugins in TerraLib.