From e483cb9ef97714d196a044a22ac55c7e455991da Mon Sep 17 00:00:00 2001 From: Richard Berger <richard.berger@temple.edu> Date: Wed, 7 Sep 2016 16:30:14 -0400 Subject: [PATCH] Use command_map to list command styles --- src/info.cpp | 7 +++---- src/input.cpp | 2 +- src/input.h | 6 ++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index 0e8136278d..bb8380aa19 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -737,10 +737,9 @@ void Info::command_styles(FILE * out) fprintf(out, "\nCommand styles (add-on input script commands):\n"); vector<string> styles; -#define COMMAND_CLASS -#define CommandStyle(key,Class) styles.push_back(#key); -#include "style_command.h" -#undef COMMAND_CLASS + for(Input::CommandCreatorMap::iterator it = input->command_map->begin(); it != input->command_map->end(); ++it) { + styles.push_back(it->first); + } print_columns(out, styles); fprintf(out, "\n\n\n"); } diff --git a/src/input.cpp b/src/input.cpp index 4ab4a6b968..905e7f0590 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -93,7 +93,7 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp) // fill map with commands listed in style_command.h - command_map = new std::map<std::string,CommandCreator>(); + command_map = new CommandCreatorMap(); #define COMMAND_CLASS #define CommandStyle(key,Class) \ diff --git a/src/input.h b/src/input.h index c1947fee03..33a271ccdf 100644 --- a/src/input.h +++ b/src/input.h @@ -53,10 +53,12 @@ class Input : protected Pointers { FILE **infiles; // list of open input files - protected: + public: typedef void (*CommandCreator)(LAMMPS *, int, char **); - std::map<std::string,CommandCreator> *command_map; + typedef std::map<std::string,CommandCreator> CommandCreatorMap; + CommandCreatorMap *command_map; + protected: template <typename T> static void command_creator(LAMMPS *, int, char **); private: -- GitLab