LCOV - code coverage report
Current view: top level - core - ActionShortcut.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 22 30 73.3 %
Date: 2026-03-30 13:16:06 Functions: 4 6 66.7 %

          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             : #include "ActionShortcut.h"
      23             : #include "PlumedMain.h"
      24             : #include "ActionSet.h"
      25             : 
      26             : namespace PLMD {
      27             : 
      28          24 : void ActionShortcut::registerKeywords( Keywords& keys ) {
      29          24 :   Action::registerKeywords( keys );
      30          48 :   keys.add("hidden","IS_SHORTCUT","hidden keyword to tell if actions are shortcuts so that example generator can provide expansions of shortcuts");
      31          24 : }
      32             : 
      33          12 : ActionShortcut::ActionShortcut(const ActionOptions&ao):
      34             :   Action(ao),
      35          12 :   shortcutlabel(label) {
      36             :   std::string s;
      37          12 :   Tools::convert(plumed.getActionSet().size(),s);
      38          12 :   if( shortcutlabel==("@" + s) ) {
      39             :     std::string t;
      40           6 :     Tools::convert(plumed.getActionSet().size()+1,t);
      41          12 :     shortcutlabel="@" + t;
      42             :   } else {
      43          12 :     label = ("@" + s);
      44             :   }
      45          12 : }
      46             : 
      47          36 : void ActionShortcut::readInputLine( const std::string& input ) {
      48          36 :   std::string f_input = input;
      49          36 :   savedInputLines.push_back( input );
      50          36 :   if( update_from!=std::numeric_limits<double>::max() ) {
      51             :     std::string ufrom;
      52           0 :     Tools::convert( update_from, ufrom );
      53           0 :     f_input += " UPDATE_FROM=" + ufrom;
      54             :   }
      55          36 :   if( update_until!=std::numeric_limits<double>::max() ) {
      56             :     std::string util;
      57           0 :     Tools::convert( update_until, util );
      58           0 :     f_input += " UPDATE_UNTIL=" + util;
      59             :   }
      60          72 :   if( keywords.exists("RESTART") ) {
      61           0 :     if( restart ) {
      62             :       f_input += " RESTART=YES";
      63             :     }
      64           0 :     if( !restart ) {
      65             :       f_input += " RESTART=NO";
      66             :     }
      67             :   }
      68          36 :   plumed.readInputLine( f_input );
      69          36 : }
      70             : 
      71          54 : const std::string & ActionShortcut::getShortcutLabel() const {
      72          54 :   return shortcutlabel;
      73             : }
      74             : 
      75           0 : std::vector<std::string> ActionShortcut::getSavedInputLines() const {
      76           0 :   return savedInputLines;
      77             : }
      78             : 
      79             : }

Generated by: LCOV version 1.16