diff --git a/src/core/ActionSet.cpp b/src/core/ActionSet.cpp index da711c95d70b0fc7b9d0ce33033aa5313c79cf85..f7f29806c82a7310a5fddbf78391223a3316a876 100644 --- a/src/core/ActionSet.cpp +++ b/src/core/ActionSet.cpp @@ -40,23 +40,4 @@ void ActionSet::clearDelete() { } -std::string ActionSet::getLabelList() const { - std::string outlist; - for(const auto & p : (*this)) { - outlist+=dynamic_cast<Action*>(p)->getLabel()+" "; - }; - return outlist; -} - -std::vector<std::string> ActionSet::getLabelVector() const { - std::vector<std::string> outlist; - for(const auto & p : (*this)) { - outlist.push_back(dynamic_cast<Action*>(p)->getLabel()); - }; - return outlist; -} - - - - } diff --git a/src/core/ActionSet.h b/src/core/ActionSet.h index 3d5ea6fc7805f3203e49736733aee4e5a93c55d1..63136f002cb220ea97a1850c39cd36075ebeb1cc 100644 --- a/src/core/ActionSet.h +++ b/src/core/ActionSet.h @@ -61,8 +61,12 @@ public: template <class T> T selectWithLabel(const std::string&s)const; /// get the labels in the list of actions in form of a string (useful to debug) +/// Only classes that can be dynamic casted to T are reported + template <class T> std::string getLabelList() const; /// get the labels in the form of a vector of strings +/// Only classes that can be dynamic casted to T are reported + template <class T> std::vector<std::string> getLabelVector() const; }; @@ -98,6 +102,27 @@ std::vector<Action*> ActionSet::selectNot()const { return ret; } +template <class T> +std::string ActionSet::getLabelList() const { + std::string outlist; + for(const auto & p : (*this)) { + if(dynamic_cast<T>(p)) outlist+=p->getLabel()+" "; + }; + return outlist; +} + + +template <class T> +std::vector<std::string> ActionSet::getLabelVector() const { + std::vector<std::string> outlist; + for(const auto & p : (*this)) { + if(dynamic_cast<T>(p)) outlist.push_back(p->getLabel()); + }; + return outlist; +} + + + } #endif diff --git a/src/core/ActionWithArguments.cpp b/src/core/ActionWithArguments.cpp index 5865375d89d95c2b9f9ef1daec91595926ff7478..3a211f6d6772d31b58753f176e92e6ca5beb42fb 100644 --- a/src/core/ActionWithArguments.cpp +++ b/src/core/ActionWithArguments.cpp @@ -148,8 +148,8 @@ void ActionWithArguments::interpretArgumentList(const std::vector<std::string>& // Take all the values from an action with a specific name ActionWithValue* action=plumed.getActionSet().selectWithLabel<ActionWithValue*>(a); if(!action) { - std::string str=" (hint! the actions in this ActionSet are: "; - str+=plumed.getActionSet().getLabelList()+")"; + std::string str=" (hint! the actions with value in this ActionSet are: "; + str+=plumed.getActionSet().getLabelList<ActionWithValue*>()+")"; error("cannot find action named " + a + str); } if( action->getNumberOfComponents()==0 ) error("found " + a +".* indicating use all components calculated by action with label " + a + " but this action has no components"); @@ -168,8 +168,8 @@ void ActionWithArguments::interpretArgumentList(const std::vector<std::string>& // Take values with a specific name ActionWithValue* action=plumed.getActionSet().selectWithLabel<ActionWithValue*>(a); if(!action) { - std::string str=" (hint! the actions in this ActionSet are: "; - str+=plumed.getActionSet().getLabelList()+")"; + std::string str=" (hint! the actions with value in this ActionSet are: "; + str+=plumed.getActionSet().getLabelList<ActionWithValue*>()+")"; error("cannot find action named " + a +str); } if( !(action->exists(c[i])) ) { @@ -190,8 +190,8 @@ void ActionWithArguments::interpretArgumentList(const std::vector<std::string>& } else { ActionWithValue* action=plumed.getActionSet().selectWithLabel<ActionWithValue*>(c[i]); if(!action) { - std::string str=" (hint! the actions in this ActionSet are: "; - str+=plumed.getActionSet().getLabelList()+")"; + std::string str=" (hint! the actions with value in this ActionSet are: "; + str+=plumed.getActionSet().getLabelList<ActionWithValue*>()+")"; error("cannot find action named " + c[i] + str ); } if( !(action->exists(c[i])) ) {