27 #include "../../../../common/Version.h"
28 #include "../../../../common/StringUtils.h"
35 #define PLUGIN_H_FILE_NAME "Plugin.h"
36 #define PLUGIN_CPP_FILE_NAME "Plugin.cpp"
37 #define PLUGIN_CONFIG_FILE_NAME "Config.h"
51 std::string fileName = sourcePath;
55 file.open(fileName.c_str());
61 insertTerraLibHeader(file);
70 file <<
"// TerraLib Includes\n";
71 file <<
"#include \"Config.h\"\n";
72 file <<
"#include <terralib/plugin/Plugin.h>\n\n";
75 file <<
"namespace te\n";
77 file <<
" namespace qt\n";
79 file <<
" namespace plugins\n";
81 file <<
" namespace " + nameSpace +
"\n";
83 file <<
" class Plugin : public te::plugin::Plugin\n";
87 file <<
" Plugin(const te::plugin::PluginInfo& pluginInfo);\n";
89 file <<
" ~Plugin();\n";
91 file <<
" void startup();\n";
93 file <<
" void shutdown();\n";
96 file <<
" } // end namespace " + nameSpace +
"\n";
97 file <<
" } // end namespace plugins\n";
98 file <<
" } // end namespace qt\n";
99 file <<
"} // end namespace te\n";
101 file <<
"\nPLUGIN_CALL_BACK_DECLARATION(" + getExportMacro(nameSpace) +
")\n";
113 std::string fileName = sourcePath;
117 file.open(fileName.c_str());
123 insertTerraLibHeader(file);
129 file <<
"// TerraLib Includes\n";
130 file <<
"#include \"Plugin.h\"\n\n";
131 file <<
"#include <terralib/common/Config.h>\n";
132 file <<
"#include <terralib/common/Logger.h>\n";
133 file <<
"#include <terralib/common/Translator.h>\n\n";
136 file <<
"te::qt::plugins::" + nameSpace +
"::Plugin::Plugin(const te::plugin::PluginInfo& pluginInfo)\n";
137 file <<
" : te::plugin::Plugin(pluginInfo)\n";
142 file <<
"te::qt::plugins::" + nameSpace +
"::Plugin::~Plugin()\n";
149 file <<
"void te::qt::plugins::" + nameSpace +
"::Plugin::startup()\n";
151 file <<
" if(m_initialized)\n";
152 file <<
" return;\n";
154 file <<
"// it initializes the Translator support\n";
155 file <<
" TE_ADD_TEXT_DOMAIN(TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_TEXT_DOMAIN, TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_TEXT_DOMAIN_DIR, \"UTF-8\");\n";
157 file <<
" TE_LOG_TRACE(TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"(\"Plugin " + projName +
" startup!\"));\n";
159 file <<
" m_initialized = true;\n";
163 file <<
"void te::qt::plugins::" + nameSpace +
"::Plugin::shutdown()\n";
165 file <<
" if(!m_initialized)\n";
166 file <<
" return;\n";
168 file <<
" TE_LOG_TRACE(TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"(\"Plugin " + projName +
" shutdown!\"));\n";
170 file <<
" m_initialized = false;\n";
174 file <<
"PLUGIN_CALL_BACK_IMPL(te::qt::plugins::" + nameSpace +
"::Plugin)\n";
183 std::string fileName = sourcePath;
187 file.open(fileName.c_str());
193 insertTerraLibHeader(file);
205 file <<
" \\def TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_PLUGIN_NAME\n";
207 file <<
" \\brief It contains the plugin name.\n";
209 file <<
"#define TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_PLUGIN_NAME \"" + projName +
"\"\n\n";
213 file <<
" \\def TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_TEXT_DOMAIN\n";
215 file <<
" \\brief It contains the name of the text domain used in the translation of messages in this plugin.\n";
217 file <<
"#define TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_TEXT_DOMAIN \"" + projName +
"\"\n\n";
221 file <<
" \\def TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_TEXT_DOMAIN_DIR\n";
223 file <<
" \\brief It contains the translation catalog directory.\n";
225 file <<
"#define TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_TEXT_DOMAIN_DIR \"locale\"\n\n";
229 file <<
" \\def TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"\n";
231 file <<
" \\brief It marks a string in order to get translated.\n";
233 file <<
"#define TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"(message) TR(message, TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_TEXT_DOMAIN)\n\n";
237 file <<
" \\def " + getExportMacro(nameSpace) +
"\n";
239 file <<
" \\brief You can use this macro in order to export/import classes and functions from all plug-ins files.\n";
241 file <<
" \\note To compile plug-ins in Windows, remember to insert " + exportMacro +
" into the project's list of defines.\n";
243 file <<
"#ifdef WIN32\n";
244 file <<
" #ifdef " + exportMacro +
"\n";
245 file <<
" #define " + getExportMacro(nameSpace) +
" __declspec(dllexport) // export DLL information\n";
247 file <<
" #define " + getExportMacro(nameSpace) +
" __declspec(dllimport) // import DLL information\n";
248 file <<
" #endif \n";
250 file <<
" #define " + getExportMacro(nameSpace) +
"\n";
251 file <<
"#endif\n\n";
261 time_t now = time(0);
262 char* dt = ctime(&now);
263 std::string currentTime = dt;
266 std::string defaultHeader =
"";
268 defaultHeader +=
"/**********************************************************************\n";
269 defaultHeader +=
"** This file was automatically generated by TerraView - Plugin Builder\n";
270 defaultHeader +=
"** TerraLib Version: " + teVersion +
" \n";
271 defaultHeader +=
"** File: " + fileName +
"\n";
272 defaultHeader +=
"** Date: " + currentTime;
273 defaultHeader +=
"**********************************************************************/\n";
275 stream << defaultHeader.c_str();
281 std::string defaultHeader =
"";
283 defaultHeader +=
"/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.\n";
284 defaultHeader +=
"\n";
285 defaultHeader +=
" This file is part of the TerraLib - a Framework for building GIS enabled applications.\n";
286 defaultHeader +=
"\n";
287 defaultHeader +=
" TerraLib is free software: you can redistribute it and/or modify\n";
288 defaultHeader +=
" it under the terms of the GNU Lesser General Public License as published by\n";
289 defaultHeader +=
" the Free Software Foundation, either version 3 of the License,\n";
290 defaultHeader +=
" or (at your option) any later version.\n";
291 defaultHeader +=
"\n";
292 defaultHeader +=
" TerraLib is distributed in the hope that it will be useful,\n";
293 defaultHeader +=
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
294 defaultHeader +=
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
295 defaultHeader +=
" GNU Lesser General Public License for more details.\n";
296 defaultHeader +=
"\n";
297 defaultHeader +=
" You should have received a copy of the GNU Lesser General Public License\n";
298 defaultHeader +=
" along with TerraLib. See COPYING. If not, write to\n";
299 defaultHeader +=
" TerraLib Team at <terralib-team@terralib.org>.\n";
300 defaultHeader +=
"*/\n";
302 stream << defaultHeader.c_str();
308 std::string info =
"";
311 info +=
" \\file " + fileName +
"\n";
313 info +=
" \\brief ...\n";
316 stream << info.c_str();
322 std::string str =
"";
326 int pos = fileName.find(
".");
327 std::string body = fileName.substr(0, pos);
330 str +=
"#ifndef __TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_INTERNAL_" + flUPpperCase +
"_H\n";
331 str +=
"#define __TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_INTERNAL_" + flUPpperCase +
"_H\n";
333 stream << str.c_str();
339 std::string str =
"";
343 int pos = fileName.find(
".");
344 std::string body = fileName.substr(0, pos);
347 str +=
"#endif //__TE_QT_PLUGIN_BUILDER_" + nsUpperCase +
"_INTERNAL_" + flUPpperCase +
"_H\n";
350 stream << str.c_str();
358 std::string tag =
"TEQTPLUGIN" + nsUpperCase +
"EXPORT";
#define PLUGIN_CPP_FILE_NAME
static std::string asString()
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
#define PLUGIN_H_FILE_NAME
This class is used to create the source files for the new plugin builded.
#define PLUGIN_CONFIG_FILE_NAME