Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2018-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_core_ActionShortcut_h 23 : #define __PLUMED_core_ActionShortcut_h 24 : 25 : #include "Action.h" 26 : 27 : namespace PLMD { 28 : 29 : /** 30 : \ingroup MULTIINHERIT 31 : Action used to create a command that expands to multiple PLMD::Action commands when read in during input 32 : */ 33 : class ActionShortcut : 34 : public virtual Action { 35 : friend class ActionSet; 36 : private: 37 : std::string shortcutlabel; 38 : std::vector<std::string> savedInputLines; 39 : std::vector<std::string> savedOutputs; 40 : void addToSavedInputLines( const std::string& line ); 41 : protected: 42 : std::string getUpdateLimits() const ; 43 : public: 44 : const std::string & getShortcutLabel() const ; 45 : static void registerKeywords( Keywords& keys ); 46 : /// Constructor 47 : explicit ActionShortcut(const ActionOptions&ao); 48 : /// Read keywords 49 : void readShortcutKeywords( const Keywords& keys, std::map<std::string,std::string>& keymap ); 50 : /// Read a line of input and create appropriate actions 51 : void readInputLine( const std::string& input, bool saveline=true ); 52 : /// Add a comment to your shortcut output 53 : void addCommentToShortcutOutput( const std::string& input ); 54 : /// Do nothing. 55 0 : void calculate() override {} 56 : /// Do nothing. 57 0 : void apply() override {} 58 : /// Get the lines of the shortcut that were read in 59 : std::vector<std::string> getSavedInputLines() const ; 60 : /// Get the labels of the actions that this creates 61 : std::vector<std::string> getSavedOutputs() const ; 62 : /// Take everything that was input to this action and convert it to a string 63 : std::string convertInputLineToString(); 64 : /// This sorts out the reading of arguments from shortcuts 65 : void interpretDataLabel( const std::string& mystr, Action* myuser, std::vector<Value*>& args ) const ; 66 59 : ActionShortcut* castToActionShortcut() noexcept final { return this; } 67 : }; 68 : 69 : } 70 : 71 : #endif