Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2011-2023 The plumed team 3 : (see the PEOPLE file at the root of the distribution for a list of names) 4 : 5 : See http://www.plumed.org for more information. 6 : 7 : This file is part of plumed, version 2. 8 : 9 : plumed is free software: you can redistribute it and/or modify 10 : it under the terms of the GNU Lesser General Public License as published by 11 : the Free Software Foundation, either version 3 of the License, or 12 : (at your option) any later version. 13 : 14 : plumed is distributed in the hope that it will be useful, 15 : but WITHOUT ANY WARRANTY; without even the implied warranty of 16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 : GNU Lesser General Public License for more details. 18 : 19 : You should have received a copy of the GNU Lesser General Public License 20 : along with plumed. If not, see <http://www.gnu.org/licenses/>. 21 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 22 : #ifndef __PLUMED_colvar_ColvarShortcut_h 23 : #define __PLUMED_colvar_ColvarShortcut_h 24 : 25 : #include "core/ActionShortcut.h" 26 : 27 : namespace PLMD { 28 : namespace colvar { 29 : 30 : template <class T> 31 : class ColvarShortcut : public ActionShortcut { 32 : public: 33 : static void registerKeywords(Keywords&); 34 : explicit ColvarShortcut(const ActionOptions&); 35 : }; 36 : 37 : template <class T> 38 2016 : void ColvarShortcut<T>::registerKeywords(Keywords& keys ) { 39 2016 : T::registerKeywords( keys ); keys.remove("NO_ACTION_LOG"); 40 2016 : unsigned nkeys = keys.size(); 41 18901 : for(unsigned i=0; i<nkeys; ++i) { 42 39601 : if( keys.style( keys.get(i), "atoms" ) ) keys.reset_style( keys.get(i), "numbered" ); 43 : } 44 4032 : keys.addActionNameSuffix("_SCALAR"); keys.addActionNameSuffix("_VECTOR"); 45 2016 : } 46 : 47 : template <class T> 48 1695 : ColvarShortcut<T>::ColvarShortcut(const ActionOptions&ao): 49 : Action(ao), 50 1695 : ActionShortcut(ao) 51 : { 52 1695 : bool scalar=true; unsigned nkeys = keywords.size(); 53 5058 : if( getName()=="MASS" || getName()=="CHARGE" || getName()=="POSITION" ) { 54 306 : std::string inpt; parse("ATOMS",inpt); 55 153 : if( inpt.length()>0 ) { 56 114 : readInputLine( getShortcutLabel() + ": " + getName() + "_VECTOR ATOMS=" + inpt + " " + convertInputLineToString() ); 57 : scalar=false; 58 : } 59 : } 60 15896 : for(unsigned i=0; i<nkeys; ++i) { 61 28690 : if( keywords.style( keywords.get(i), "atoms" ) ) { 62 10608 : std::string inpt; parseNumbered( keywords.get(i), 1, inpt ); 63 5304 : if( inpt.length()>0 ) { 64 288 : readInputLine( getShortcutLabel() + ": " + getName() + "_VECTOR " + keywords.get(i) + "1=" + inpt + " " + convertInputLineToString() ); 65 : scalar=false; break; 66 : } 67 : } 68 : } 69 3063 : if( scalar ) readInputLine( getShortcutLabel() + ": " + getName() + "_SCALAR " + convertInputLineToString() ); 70 1701 : } 71 : 72 : } 73 : } 74 : #endif