Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2016-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_analysis_DataCollectionObject_h 23 : #define __PLUMED_analysis_DataCollectionObject_h 24 : 25 : #include <map> 26 : #include <vector> 27 : #include "tools/Vector.h" 28 : #include "tools/AtomNumber.h" 29 : 30 : namespace PLMD { 31 : 32 : class PDB; 33 : 34 : namespace analysis { 35 : 36 : class DataCollectionObject { 37 : friend class ReadAnalysisFrames; 38 : private: 39 : /// The label of the action in which the data is stored 40 : std::string myaction; 41 : /// The list of atom numbers that are stored in the object 42 : std::vector<AtomNumber> indices; 43 : /// The list of atomic positions 44 : std::vector<Vector> positions; 45 : /// The map containing the arguments that we are storing 46 : std::map<std::string,double> args; 47 : public: 48 : /// Set the names and atom numbers 49 : void setAtomNumbersAndArgumentNames( const std::string& action_label, const std::vector<AtomNumber>& ind, const std::vector<std::string>& arg_names ); 50 : /// Set the positions of all the atoms 51 : void setAtomPositions( const std::vector<Vector>& pos ); 52 : /// Set the value of one of the arguments 53 : void setArgument( const std::string& name, const double& value ); 54 : /// Return one of the atomic positions 55 : Vector getAtomPosition( const AtomNumber& ind ) const ; 56 : /// Get the value of one of the arguments 57 : double getArgumentValue( const std::string& name ) const ; 58 : /// Transfer the data inside the object to a PDB object 59 : bool transferDataToPDB( PDB& mypdb ); 60 : }; 61 : 62 : inline 63 : Vector DataCollectionObject::getAtomPosition( const AtomNumber& ind ) const { 64 : return positions[ind.index()]; 65 : } 66 : 67 : inline 68 6517 : double DataCollectionObject::getArgumentValue( const std::string& name ) const { 69 : std::map<std::string,double>::const_iterator it = args.find(name); 70 6517 : if( it != args.end() ) return it->second; 71 2106 : std::size_t dot=name.find_first_of('.'); std::string a=name.substr(0,dot); 72 4212 : if( a==myaction ) return args.find( name.substr(dot+1) )->second; 73 0 : else plumed_merror("could not find required data in collection object"); 74 : } 75 : 76 : } 77 : } 78 : 79 : #endif