[Fawkes Git] branch/jrothe/plugin_generator: plugin_generator: add support for filenames with a dash

Johannes Rothe johannes.rothe at rwth-aachen.de
Tue Sep 6 13:26:28 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, jrothe/plugin_generator has been updated
        to  f54c6b4bf01f4d5c926500e9217a3abc27b3de07 (commit)
      from  0aae62787a2df4dd2e207091ada38bb5f0f3d3ce (commit)

http://git.fawkesrobotics.org/fawkes.git/jrothe/plugin_generator

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit f54c6b4bf01f4d5c926500e9217a3abc27b3de07
Author:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
AuthorDate: Tue Sep 6 13:04:32 2016 +0200
Commit:     Johannes Rothe <johannes.rothe at rwth-aachen.de>
CommitDate: Tue Sep 6 13:04:32 2016 +0200

    plugin_generator: add support for filenames with a dash

http://git.fawkesrobotics.org/fawkes.git/commit/f54c6b4
http://trac.fawkesrobotics.org/changeset/f54c6b4

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/tools/plugin_generator/plugin_generator.cpp |   25 +++++++++++++++++++---
 src/tools/plugin_generator/plugin_generator.h   |    2 +
 2 files changed, 23 insertions(+), 4 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* f54c6b4bf01f4d5c926500e9217a3abc27b3de07 - - - - - - - - - -
Author:  Johannes Rothe <johannes.rothe at rwth-aachen.de>
Date:    Tue Sep 6 13:04:32 2016 +0200
Subject: plugin_generator: add support for filenames with a dash

 src/tools/plugin_generator/plugin_generator.cpp |   25 +++++++++++++++++++---
 src/tools/plugin_generator/plugin_generator.h   |    2 +
 2 files changed, 23 insertions(+), 4 deletions(-)

_Diff for modified files_:
diff --git a/src/tools/plugin_generator/plugin_generator.cpp b/src/tools/plugin_generator/plugin_generator.cpp
index 2237427..3b14aa3 100644
--- a/src/tools/plugin_generator/plugin_generator.cpp
+++ b/src/tools/plugin_generator/plugin_generator.cpp
@@ -69,11 +69,12 @@ PluginGenerator::PluginGenerator(std::string directory,
   _filename_makefile   = "Makefile";
 
   _plugin_name = plugin_name;
+  _plugin_name_underscore = replace_dash_w_undescore(_plugin_name);
 
-  _class_name_thread = format_class_name(_plugin_name, "Thread");
-  _class_name_plugin = format_class_name(_plugin_name, "Plugin");
+  _class_name_thread = format_class_name(_plugin_name_underscore, "Thread");
+  _class_name_plugin = format_class_name(_plugin_name_underscore, "Plugin");
 
-  _deflector = "__PLUGINS_" + fawkes::StringConversions::to_upper(plugin_name) + "THREAD_H_";
+  _deflector = "__PLUGINS_" + fawkes::StringConversions::to_upper(_plugin_name_underscore) + "THREAD_H_";
 }
 
 
@@ -276,7 +277,7 @@ PluginGenerator::write_makefile (FILE* f)
           "LIBS_%s = m fawkescore fawkesutils fawkesaspects fawkesbaseapp \\\n"
           "                      fawkesblackboard fawkesinterface\n\n"
           "OBJS_%s = %s %s\n\n",
-          _plugin_name.c_str(), _plugin_name.c_str(), filename_plugin_o.c_str(),
+          _plugin_name_underscore.c_str(), _plugin_name_underscore.c_str(), filename_plugin_o.c_str(),
           filename_thread_o.c_str()
           );
   fprintf(f,
@@ -287,6 +288,22 @@ PluginGenerator::write_makefile (FILE* f)
 }
 
 /*
+ * Replace dash with undescore
+ *
+ * Example: plugin-generator to plugin_generator
+ */
+std::string
+PluginGenerator::replace_dash_w_undescore(std::string source)
+{
+  for(std::string::size_type i = 0; (i = source.find("-", i)) != std::string::npos;)
+  {
+    source.replace(i, 1, "_");
+    i++;
+  }
+  return source;
+}
+
+/*
  * Format a lowercase plugin name to CamelCase plugin name and append
  * a string to specify the name
  *
diff --git a/src/tools/plugin_generator/plugin_generator.h b/src/tools/plugin_generator/plugin_generator.h
index f857c92..5469a41 100644
--- a/src/tools/plugin_generator/plugin_generator.h
+++ b/src/tools/plugin_generator/plugin_generator.h
@@ -46,11 +46,13 @@ class PluginGenerator
   void write_header(FILE *f, std::string filename);
   void write_deflector(FILE *f);
   std::string format_class_name(std::string plugin_name, std::string append);
+  std::string replace_dash_w_undescore(std::string source);
   void generate();
 
  private:
   std::string _dir;
   std::string _plugin_name;
+  std::string _plugin_name_underscore;
   std::string _class_name_thread;
   std::string _class_name_plugin;
   std::string _description;




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list