All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Include.cpp
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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 "core/Action.h"
23 #include "core/ActionRegister.h"
24 #include "core/PlumedMain.h"
25 #include "tools/Exception.h"
26 
27 using namespace std;
28 
29 namespace PLMD{
30 namespace generic{
31 
32 //+PLUMEDOC GENERIC INCLUDE
33 /*
34 Includes an external input file, similar to "#include" in C preprocessor.
35 
36 Useful to split very large plumed.dat files.
37 
38 \par Examples
39 
40 This input
41 \verbatim
42 c1: COM ATOMS=1-100
43 c2: COM ATOMS=101-202
44 d: DISTANCE ARG=c1,c2
45 PRINT ARG=d
46 \endverbatim
47 
48 can be replaced with
49 \verbatim
50 INCLUDE FILE=pippo.dat
51 d: DISTANCE ARG=c1,c2
52 PRINT ARG=d
53 \endverbatim
54 
55 where the content of file pippo.dat is
56 \verbatim
57 c1: COM ATOMS=1-100
58 c2: COM ATOMS=101-202
59 \endverbatim
60 
61 (see also \ref COM, \ref DISTANCE, and \ref PRINT).
62 
63 */
64 //+ENDPLUMEDOC
65 
66 class Include :
67  public Action
68 {
69 public:
70  static void registerKeywords( Keywords& keys );
71  Include(const ActionOptions&ao);
72  void calculate(){}
73  void apply(){}
74 };
75 
76 PLUMED_REGISTER_ACTION(Include,"INCLUDE")
77 
78 void Include::registerKeywords( Keywords& keys ){
79  Action::registerKeywords(keys);
80  keys.add("compulsory","FILE","file to be included");
81 }
82 
83 Include::Include(const ActionOptions&ao):
84 Action(ao)
85 {
86  std::string f;
87  parse("FILE",f);
88  checkRead();
89  plumed.readInputFile(f);
90 }
91 
92 }
93 }
94 
void calculate()
Calculate an Action.
Definition: Include.cpp:72
void checkRead()
Check if Action was properly read.
Definition: Action.cpp:161
STL namespace.
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
Definition: Action.h:273
This class holds the keywords and their documentation.
Definition: Keywords.h:36
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
Provides the keyword INCLUDE
Definition: Include.cpp:66
Base class for all the input Actions.
Definition: Action.h:60
Main plumed object.
Definition: Plumed.h:201
void apply()
Apply an Action.
Definition: Include.cpp:73