FreeFOAM The Cross-Platform CFD Toolkit
functionObjectList.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjectList
26 
27 Description
28  List of function objects with start(), execute() and end() functions
29  that is called for each object.
30 
31 See Also
32  Foam::functionObject and Foam::OutputFilterFunctionObject
33 
34 SourceFiles
35  functionObjectList.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef functionObjectList_H
40 #define functionObjectList_H
41 
42 #include <OpenFOAM/PtrList.H>
44 #include <OpenFOAM/SHA1Digest.H>
45 #include <OpenFOAM/HashTable.H>
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class functionObjectList Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  private PtrList<functionObject>
59 {
60  // Private data
61 
62  //- A list of SHA1 digests for the function object dictionaries
63  List<SHA1Digest> digests_;
64 
65  //- Quick lookup of the index into functions/digests
66  HashTable<label> indices_;
67 
68  const Time& time_;
69 
70  //- The parent dictionary containing a "functions" entry
71  // This entry can either be a list or a dictionary of
72  // functionObject specifications.
73  const dictionary& parentDict_;
74 
75  //- Switch for the execution of the functionObjects
76  bool execution_;
77 
78  //- Tracks if read() was called while execution is on
79  bool updated_;
80 
81 
82  // Private Member Functions
83 
84  //- Remove and return the function object pointer by name,
85  // and returns the old index via the parameter.
86  // Returns a NULL pointer (and index -1) if it didn't exist.
87  functionObject* remove(const word&, label& oldIndex);
88 
89  //- Disallow default bitwise copy construct
91 
92  //- Disallow default bitwise assignment
93  void operator=(const functionObjectList&);
94 
95 
96 public:
97 
98  // Constructors
99 
100  //- Construct from Time and the execution setting
101  // The functionObject specifications are read from the controlDict
102  functionObjectList
103  (
104  const Time&,
105  const bool execution=true
106  );
107 
108 
109  //- Construct from Time, a dictionary with "functions" entry
110  // and the execution setting.
111  // @param[in] parentDict - the parent dictionary containing
112  // a "functions" entry, which can either be a list or a dictionary
113  // of functionObject specifications.
114  functionObjectList
115  (
116  const Time&,
117  const dictionary& parentDict,
118  const bool execution=true
119  );
120 
121 
122  // Destructor
123 
124  virtual ~functionObjectList();
125 
126 
127  // Member Functions
128 
129  //- Return the number of elements in the List.
131 
132  //- Return true if the List is empty (ie, size() is zero).
134 
135  //- Access to the functionObjects
137 
138  //- Clear the list of function objects
139  virtual void clear();
140 
141 
142  //- Switch the function objects on
143  virtual void on();
144 
145  //- Switch the function objects off
146  virtual void off();
147 
148  //- Return the execution status (on/off) of the function objects
149  virtual bool status() const;
150 
151 
152  //- Called at the start of the time-loop
153  virtual bool start();
154 
155  //- Called at each ++ or += of the time-loop
156  virtual bool execute();
157 
158  //- Called when Time::run() determines that the time-loop exits
159  virtual bool end();
160 
161  //- Read and set the function objects if their data have changed
162  virtual bool read();
163 
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************ vim: set sw=4 sts=4 et: ************************ //