Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2017-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_DataFetchingObject_h 23 : #define __PLUMED_core_DataFetchingObject_h 24 : 25 : #include <string> 26 : #include <vector> 27 : #include <set> 28 : #include <map> 29 : #include <memory> 30 : 31 : #include "tools/TypesafePtr.h" 32 : 33 : namespace PLMD { 34 : 35 : class ActionSet; 36 : class PlumedMain; 37 : class ActionWithValue; 38 : class Value; 39 : 40 : class DataFetchingObject { 41 : protected: 42 : /// Pointers to the various actions required by the grabber 43 : std::vector<ActionWithValue*> myactions; 44 : /// The values required by the user 45 : std::vector<Value*> myvalues; 46 : /// A copy of the plumed main object 47 : PlumedMain & plumed; 48 : public: 49 : static std::unique_ptr<DataFetchingObject> create(unsigned n, PlumedMain& p); 50 : /// A constructor so that we can create the plumed main object 51 : explicit DataFetchingObject(PlumedMain&p); 52 405175 : virtual ~DataFetchingObject() {} 53 : /// 54 : bool activate() const ; 55 : /// Return the rank required for a particular key 56 : static void get_rank( const ActionSet& a, const std::string& key, const std::string& type, const TypesafePtr & rank ); 57 : /// Return the shape required for a particular key 58 : static void get_shape( const ActionSet& a, const std::string& key, const std::string& type, const TypesafePtr & dims ); 59 : /// Find the action that calculates a particular value 60 : static ActionWithValue* findAction( const ActionSet& a, const std::string& key ); 61 : /// Set the pointer to the data 62 : virtual void setData( const std::string& key, const std::string& type, const TypesafePtr & outval )=0; 63 : /// After calc has been performed grab all the data and put it in the relevant arrays 64 : virtual void finishDataGrab()=0; 65 : }; 66 : 67 : } 68 : #endif