LCOV - code coverage report
Current view: top level - vesselbase - ValueVessel.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 4 4 100.0 %
Date: 2024-10-11 08:09:47 Functions: 0 0 -

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-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_vesselbase_ValueVessel_h
      23             : #define __PLUMED_vesselbase_ValueVessel_h
      24             : 
      25             : #include <string>
      26             : #include <cstring>
      27             : #include <vector>
      28             : #include <memory>
      29             : 
      30             : #include "Vessel.h"
      31             : #include "core/Value.h"
      32             : 
      33             : namespace PLMD {
      34             : namespace vesselbase {
      35             : 
      36             : class ValueVessel : public Vessel {
      37             : private:
      38             : // unique pointer with the same scope as final_value
      39             :   std::unique_ptr<Value> final_value_ptr;
      40             : // this pointer either points to a non-owned Value or to final_value_ptr
      41             :   Value* final_value;
      42             : protected:
      43             : /// The component that is being averaged/accumulated whatever
      44             :   unsigned mycomp;
      45             : /// Set the final value
      46             :   void setOutputValue( const double& val );
      47             : public:
      48             :   static void registerKeywords( Keywords& keys );
      49             :   explicit ValueVessel( const VesselOptions& da );
      50             :   std::string description() override;
      51             :   virtual std::string value_descriptor()=0;
      52             :   bool applyForce( std::vector<double>& forces ) override;
      53             :   double getOutputValue() const ;
      54             :   Value* getFinalValue() const ;
      55             : };
      56             : 
      57             : inline
      58             : Value* ValueVessel::getFinalValue() const {
      59     2406221 :   return final_value;
      60             : }
      61             : 
      62             : inline
      63             : double ValueVessel::getOutputValue() const {
      64        3389 :   return final_value->get();
      65             : }
      66             : 
      67             : inline
      68             : void ValueVessel::setOutputValue( const double& val ) {
      69        2079 :   final_value->set( val );
      70         251 : }
      71             : 
      72             : }
      73             : }
      74             : #endif

Generated by: LCOV version 1.15