From 3be870e0e1ac2e950f41be1c0c3bdbdc766ac696 Mon Sep 17 00:00:00 2001 From: Gareth Aneurin Tribello Date: Tue, 26 Nov 2024 17:07:37 +0000 Subject: [PATCH] Added functionality to keep track of deprecated actions in syntax file --- src/cltools/GenJson.cpp | 10 ++++++++++ src/core/ActionRegister.cpp | 7 ++++--- src/multicolvar/DumpMultiColvar.cpp | 1 + src/multicolvar/MFilterLess.cpp | 1 + src/multicolvar/MFilterMore.cpp | 1 + src/multicolvar/UWalls.cpp | 1 + src/tools/Keywords.cpp | 9 +++++++++ src/tools/Keywords.h | 6 ++++++ 8 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/cltools/GenJson.cpp b/src/cltools/GenJson.cpp index 8c9adec6ce..44ae7ced84 100644 --- a/src/cltools/GenJson.cpp +++ b/src/cltools/GenJson.cpp @@ -123,6 +123,16 @@ int GenJson::main(FILE* in, FILE*out,Communicator& pc) { // Now output keyword information Keywords keys; actionRegister().getKeywords( action_names[i], keys ); std::cout<<" \"displayname\" : \""< ActionRegister::create(const std::vector & images auto content=get(images,ao.line[0]); Keywords keys; keys.thisactname = ao.line[0]; - content.keys(keys); + keys.replaceaction = "none"; content.keys(keys); ActionOptions nao( ao,keys ); auto fullPath=getFullPath(images,ao.line[0]); nao.setFullPath(fullPath); @@ -79,7 +79,7 @@ bool ActionRegister::printTemplate(const std::string& action, bool include_optio //no need to insert the try/catch block: check will ensure that action is known if( check(action) ) { Keywords keys; keys.thisactname = action; - get(action).keys(keys); + keys.replaceaction = "none"; get(action).keys(keys); keys.print_template(action, include_optional); return true; } else { @@ -101,6 +101,7 @@ bool ActionRegister::getKeywords(const std::string& action, Keywords& keys) { //no need to insert the try/catch block: check will ensure that action is known if(check(action)) { keys.thisactname = action; + keys.replaceaction = "none"; get(action).keys(keys); return true; } @@ -108,7 +109,7 @@ bool ActionRegister::getKeywords(const std::string& action, Keywords& keys) { } void ActionRegister::getKeywords(const std::vector & images, const std::string& action, Keywords& keys) { - auto content=get(images,action); keys.thisactname = action; content.keys(keys); + auto content=get(images,action); keys.thisactname = action; keys.replaceaction = "none"; content.keys(keys); } } diff --git a/src/multicolvar/DumpMultiColvar.cpp b/src/multicolvar/DumpMultiColvar.cpp index b716a99cef..a0b04d25d8 100644 --- a/src/multicolvar/DumpMultiColvar.cpp +++ b/src/multicolvar/DumpMultiColvar.cpp @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(DumpMultiColvar,"DUMPMULTICOLVAR") void DumpMultiColvar::registerKeywords(Keywords& keys) { ActionShortcut::registerKeywords( keys ); + keys.setDeprecated("DUMPATOMS"); keys.add("compulsory","DATA","the vector you wish to transform"); keys.add("compulsory","FILE","the file that you would like to output the data to"); keys.remove("HAS_VALUES"); keys.needsAction("DUMPATOMS"); diff --git a/src/multicolvar/MFilterLess.cpp b/src/multicolvar/MFilterLess.cpp index 83f1978515..b8f0c817f3 100644 --- a/src/multicolvar/MFilterLess.cpp +++ b/src/multicolvar/MFilterLess.cpp @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(MFilterLess,"MFILTER_LESS") void MFilterLess::registerKeywords(Keywords& keys) { ActionShortcut::registerKeywords( keys ); + keys.setDeprecated("LESS_THAN"); keys.add("compulsory","DATA","the vector you wish to transform"); keys.add("compulsory","SWITCH","the switching function that transform"); keys.setValueDescription("vector","a vector that has the same dimension as the input vector with elements equal to one if the corresponding component of the vector is less than a tolerance and zero otherwise"); diff --git a/src/multicolvar/MFilterMore.cpp b/src/multicolvar/MFilterMore.cpp index 363a773891..2507d1b3a8 100644 --- a/src/multicolvar/MFilterMore.cpp +++ b/src/multicolvar/MFilterMore.cpp @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(MFilterMore,"MFILTER_MORE") void MFilterMore::registerKeywords(Keywords& keys) { ActionShortcut::registerKeywords( keys ); + keys.setDeprecated("MORE_THAN"); keys.add("compulsory","DATA","the vector you wish to transform"); keys.add("compulsory","SWITCH","the switching function that transform"); keys.addFlag("LOWMEM",false,"this flag does nothing and is present only to ensure back-compatibility"); diff --git a/src/multicolvar/UWalls.cpp b/src/multicolvar/UWalls.cpp index 68892cdf57..29d6dffd61 100644 --- a/src/multicolvar/UWalls.cpp +++ b/src/multicolvar/UWalls.cpp @@ -48,6 +48,7 @@ PLUMED_REGISTER_ACTION(UWalls,"UWALLS") void UWalls::registerKeywords(Keywords& keys) { ActionShortcut::registerKeywords( keys ); + keys.setDeprecated("UPPER_WALLS"); keys.add("compulsory","DATA","the values you want to restrain"); keys.add("compulsory","AT","the radius of the sphere"); keys.add("compulsory","KAPPA","the force constant for the wall. The k_i in the expression for a wall."); diff --git a/src/tools/Keywords.cpp b/src/tools/Keywords.cpp index ca9af95d6e..4904a0ccd8 100644 --- a/src/tools/Keywords.cpp +++ b/src/tools/Keywords.cpp @@ -776,4 +776,13 @@ std::string Keywords::getDisplayName() const { return thisactname; } +void Keywords::setDeprecated( const std::string& name ) { + replaceaction = name; +} + +std::string Keywords::getReplacementAction() const { + return replaceaction; +} + + } diff --git a/src/tools/Keywords.h b/src/tools/Keywords.h index efce8b38a0..6c84a5a601 100644 --- a/src/tools/Keywords.h +++ b/src/tools/Keywords.h @@ -66,6 +66,8 @@ class Keywords { bool isatoms; /// The name of the action that has this set of keywords std::string thisactname; +/// The action to use in place of this deprecated action + std::string replaceaction; /// The names of the allowed keywords std::vector keys; /// The names of the reserved keywords @@ -217,6 +219,10 @@ class Keywords { std::string getDisplayName() const ; /// Set the display name void setDisplayName( const std::string& name ); +/// Get the action that should be used to replace this one if action has been deprecated + std::string getReplacementAction() const ; +/// Note that this action has been deprecated + void setDeprecated( const std::string& name ); }; }