ENH: codedFixedValue: refactored codedFixedValue and codedFunctionObject
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / utilities / codedFunctionObject / codedFunctionObject.H
blob7f34fc1be295e730a2812216309e2ac6082906fb
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::codedFunctionObject
27 Description
28     functionObject using dynamic code compilation.
30 SourceFiles
31     codedFunctionObject.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef codedFunctionObject_H
36 #define codedFunctionObject_H
38 #include "functionObject.H"
39 #include "codedBase.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 /*---------------------------------------------------------------------------*\
47                        Class codedFunctionObject Declaration
48 \*---------------------------------------------------------------------------*/
50 class codedFunctionObject
52     public functionObject,
53     public codedBase
55 protected:
57     // Protected data
59         //- Reference to the time database
60         const Time& time_;
62         //- Input dictionary
63         dictionary dict_;
65         word redirectType_;
67         string codeRead_;
68         string codeExecute_;
69         string codeEnd_;
71         //- Underlying functionObject
72         mutable autoPtr<functionObject> redirectFunctionObjectPtr_;
75     // Protected Member Functions
77         //- get the loaded dynamic libraries
78         virtual dlLibraryTable& libs() const;
80         //- adapt the context for the current object
81         virtual void prepare(dynamicCode &,const dynamicCodeContext&) const;
82       
83         // Return a description (type + name) for the output
84         virtual string description() const;
86         // Clear any redirected objects
87         virtual void clearRedirect() const;
89         // Get the dictionary to initialize the codeContext
90         virtual const dictionary& codeDict() const;
92 private:
94         //- Disallow default bitwise copy construct
95         codedFunctionObject(const codedFunctionObject&);
97         //- Disallow default bitwise assignment
98         void operator=(const codedFunctionObject&);
101 public:
103     //- Runtime type information
104     TypeName("coded");
107     // Constructors
109         //- Construct for given objectRegistry and dictionary.
110         //  Allow the possibility to load fields from files
111         codedFunctionObject
112         (
113             const word& name,
114             const Time& time,
115             const dictionary& dict,
116             bool readNow=true   // allow child-classes to avoid compilation
117         );
120     //- Destructor
121     virtual ~codedFunctionObject();
124     // Member Functions
126         //- Dynamically compiled functionObject
127         functionObject& redirectFunctionObject() const;
129         //- Called at the start of the time-loop
130         virtual bool start();
132         //- Called at each ++ or += of the time-loop. forceWrite overrides the
133         //  outputControl behaviour.
134         virtual bool execute(const bool forceWrite);
136         //- Called when Time::run() determines that the time-loop exits.
137         //  By default it simply calls execute().
138         virtual bool end();
140         //- Read and set the function object if its data have changed
141         virtual bool read(const dictionary&);
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 } // End namespace Foam
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 #endif
153 // ************************************************************************* //