initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / db / functionObjects / functionObjectList / functionObjectList.H
blob0b3a0354641d0d90d6833fda92429298fdc3614b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::functionObjectList
28 Description
29     List of function objects with start(), execute() and end() functions
30     that is called for each object.
32 See Also
33     Foam::functionObject and Foam::OutputFilterFunctionObject
35 SourceFiles
36     functionObjectList.C
38 \*---------------------------------------------------------------------------*/
40 #ifndef functionObjectList_H
41 #define functionObjectList_H
43 #include "PtrList.H"
44 #include "functionObject.H"
45 #include "SHA1Digest.H"
46 #include "HashTable.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 /*---------------------------------------------------------------------------*\
54                      Class functionObjectList Declaration
55 \*---------------------------------------------------------------------------*/
57 class functionObjectList
59     private PtrList<functionObject>
61     // Private data
63         //- A list of SHA1 digests for the function object dictionaries
64         List<SHA1Digest> digests_;
66         //- Quick lookup of the index into functions/digests
67         HashTable<label> indices_;
69         const Time& time_;
71         //- The parent dictionary containing a "functions" entry
72         //  This entry can either be a list or a dictionary of
73         //  functionObject specifications.
74         const dictionary& parentDict_;
76         //- Switch for the execution of the functionObjects
77         bool execution_;
79         //- Tracks if read() was called while execution is on
80         bool updated_;
83     // Private Member Functions
85         //- Remove and return the function object pointer by name,
86         //  and returns the old index via the parameter.
87         //  Returns a NULL pointer (and index -1) if it didn't exist.
88         functionObject* remove(const word&, label& oldIndex);
90         //- Disallow default bitwise copy construct
91         functionObjectList(const functionObjectList&);
93         //- Disallow default bitwise assignment
94         void operator=(const functionObjectList&);
97 public:
99     // Constructors
101         //- Construct from Time and the execution setting
102         //  The functionObject specifications are read from the controlDict
103         functionObjectList
104         (
105             const Time&,
106             const bool execution=true
107         );
110         //- Construct from Time, a dictionary with "functions" entry
111         //  and the execution setting.
112         //  @param[in]  parentDict - the parent dictionary containing
113         //    a "functions" entry, which can either be a list or a dictionary
114         //    of functionObject specifications.
115         functionObjectList
116         (
117             const Time&,
118             const dictionary& parentDict,
119             const bool execution=true
120         );
123     // Destructor
125         virtual ~functionObjectList();
128     // Member Functions
130         //- Return the number of elements in the List.
131         using PtrList<functionObject>::size;
133         //- Return true if the List is empty (ie, size() is zero).
134         using PtrList<functionObject>::empty;
136         //- Access to the functionObjects
137         using PtrList<functionObject>::operator[];
139         //- Clear the list of function objects
140         virtual void clear();
143         //- Switch the function objects on
144         virtual void on();
146         //- Switch the function objects off
147         virtual void off();
149         //- Return the execution status (on/off) of the function objects
150         virtual bool status() const;
153         //- Called at the start of the time-loop
154         virtual bool start();
156         //- Called at each ++ or += of the time-loop
157         virtual bool execute();
159         //- Called when Time::run() determines that the time-loop exits
160         virtual bool end();
162         //- Read and set the function objects if their data have changed
163         virtual bool read();
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 } // End namespace Foam
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 #endif
176 // ************************************************************************* //