Skip to content
Snippets Groups Projects
Commit 02d6d5a8 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Fix #421

Notice that I had to change to interface of a couple of functions
ActionSet:getLabelList() and getLabelVector()
adding a template parameter.
Should be harmless since these functions were used in a few places only.
parent 1d010c7e
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
......@@ -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
......
......@@ -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])) ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment