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