New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a simple module map #1063
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../scripts/test.make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type=make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "plumed/core/ModuleMap.h" | ||
#include "plumed/core/ActionRegister.h" | ||
|
||
#include <fstream> | ||
|
||
|
||
int main(){ | ||
const auto actionList=PLMD::actionRegister().getActionNames(); | ||
//just checking that all the default-registered actions are in the module map; | ||
//output should be empty, the diff will be clear | ||
//this test may break in case of adding a new LOAD mechanism on startup | ||
std::ofstream file("output"); | ||
for (const auto & name: actionList){ | ||
if(PLMD::getModuleMap().count(name)==0){ | ||
file << name << "is not in the ModuleMap\n"; | ||
} | ||
} | ||
return 0; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
Copyright (c) 2024-2024 The plumed team | ||
(see the PEOPLE file at the root of the distribution for a list of names) | ||
|
||
See http://www.plumed.org for more information. | ||
|
||
This file is part of plumed, version 2. | ||
|
||
plumed is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
plumed is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with plumed. If not, see <http://www.gnu.org/licenses/>. | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ | ||
#include "ModuleMap.h" | ||
|
||
namespace PLMD { | ||
const std::map<std::string,std::string> & getModuleMap() { | ||
static const std::map<std::string,std::string> actionToModule= { | ||
#include "ModuleMap.inc" | ||
}; | ||
return actionToModule; | ||
} | ||
} // namespace PLMD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
Copyright (c) 2024-2024 The plumed team | ||
(see the PEOPLE file at the root of the distribution for a list of names) | ||
|
||
See http://www.plumed.org for more information. | ||
|
||
This file is part of plumed, version 2. | ||
|
||
plumed is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
plumed is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with plumed. If not, see <http://www.gnu.org/licenses/>. | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ | ||
#ifndef __PLUMED_core_ModuleMap_h | ||
#define __PLUMED_core_ModuleMap_h | ||
#include <map> | ||
#include <string> | ||
namespace PLMD { | ||
const std::map<std::string,std::string> & getModuleMap(); | ||
} // namespace PLMD | ||
|
||
#endif //__PLUMED_core_ModuleMap_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#! /usr/bin/env bash | ||
# shellcheck disable=SC2059 | ||
|
||
problems="" | ||
toPrint=' {"%s", "%s"}' | ||
#regex are scary, here's a link with the flow of the regex | ||
# https://regexper.com/#PLUMED_REGISTER_ACTION%5Cs*%5C%28%5Cs*%5B0-9a-zA-Z_%5D%2B%5Cs*%2C%5Cs*%22%28%5B0-9a-zA-Z_%5D%2B%29%22%5Cs*%5C%29 | ||
regex='PLUMED_REGISTER_ACTION\s*\(\s*[0-9a-zA-Z_]+\s*,\s*"([0-9a-zA-Z_]+)"\s*\)' | ||
|
||
for module in ../*/module.type; do | ||
moduledir=${module%%/module.type} | ||
modulename=${moduledir##*/} | ||
{ | ||
for file in "$moduledir"/*.cpp; do | ||
if grep -q PLUMED_REGISTER_ACTION "${file}"; then | ||
# gawk and perl implementation in case your bash dialect do not process correctly the regex | ||
# actionName=$(gawk 'match($0,/PLUMED_REGISTER_ACTION\s*\(\s*[0-9_a-zA-Z]+\s*,\s*"([0-9a-zA-Z_]+)"\s*\)/, captured){print captured[1]}' "${file}" ) | ||
# # in case gawk does not work, here's the perl implementation: | ||
# # actionName=$(perl -ln -e'print $1 if /PLUMED_REGISTER_ACTION\s*\(\s*[0-9_a-zA-Z]+\s*,\s*"([0-9a-zA-Z_]+)"\s*\)/' "${file}") | ||
# ng=$(grep -c PLUMED_REGISTER_ACTION "${file}") | ||
# nawk=$( | ||
# cat <<EOF | wc -l | ||
# $b | ||
# EOF | ||
# ) | ||
# if [[ $ng -ne $nawk ]]; then | ||
# problems="$problems ${modulename}:${file}" | ||
# fi | ||
# for a in $actionName; do | ||
# printf "$toPrint" "$a" "$modulename" | ||
# # echo -ne "$init {\"$a\", \"$modulename\"}" | ||
# toPrint=',\n {"%s", "%s"}' | ||
# done | ||
# fi | ||
|
||
grep PLUMED_REGISTER_ACTION "${file}" | while read -r action; do | ||
# echo $action | ||
if [[ $action =~ $regex ]]; then | ||
actionName=${BASH_REMATCH[1]} | ||
printf "$toPrint" "$actionName" "$modulename" | ||
|
||
toPrint=',\n {"%s", "%s"}' | ||
fi | ||
done | ||
#also here becasue while spawns a subshell and toPrint do not get updated | ||
toPrint=',\n {"%s", "%s"}' | ||
fi | ||
done | ||
} | ||
|
||
done | ||
echo -e '\n' | ||
if [[ -n $problems ]]; then | ||
echo >&2 some problems in the following: | ||
for p in $problems; do | ||
echo >&2 $p | ||
done | ||
exit 1 | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the mac CI seems to ignore the action regitered like these:
with only a space after the ","