OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

DataEntry.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::DataEntry
00027 
00028 Description
00029     Top level data entry class for use in dictionaries. Provides a mechanism
00030     to specify a variable as a certain type, e.g. constant or table, and
00031     provide functions to return the (interpolated) value, and integral between
00032     limits.
00033 
00034 SourceFiles
00035     DataEntry.C
00036     NewDataEntry.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef DataEntry_H
00041 #define DataEntry_H
00042 
00043 #include "dictionary.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 template<class Type>
00051 class DataEntry;
00052 
00053 template<class Type>
00054 Ostream& operator<<
00055 (
00056     Ostream&,
00057     const DataEntry<Type>&
00058 );
00059 
00060 /*---------------------------------------------------------------------------*\
00061                          Class DataEntry Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 template<class Type>
00065 class DataEntry
00066 {
00067     // Private Member Functions
00068 
00069         //- Disallow default bitwise assignment
00070         void operator=(const DataEntry<Type>&);
00071 
00072 
00073 protected:
00074 
00075     // Protected data
00076 
00077         //- Name of entry
00078         const word name_;
00079 
00080 
00081 public:
00082 
00083     //- Runtime type information
00084     TypeName("DataEntry")
00085 
00086     //- Declare runtime constructor selection table
00087     declareRunTimeSelectionTable
00088     (
00089         autoPtr,
00090         DataEntry,
00091         dictionary,
00092         (
00093             const word& entryName,
00094             Istream& is
00095         ),
00096         (entryName, is)
00097     );
00098 
00099 
00100     // Constructor
00101 
00102         //- Construct from entry name
00103         DataEntry(const word& entryName);
00104 
00105         //- Copy constructor
00106         DataEntry(const DataEntry<Type>& de);
00107 
00108 
00109     //- Selector
00110     static autoPtr<DataEntry<Type> > New
00111     (
00112         const word& entryName,
00113         const dictionary& dict
00114     );
00115 
00116 
00117     //- Destructor
00118     virtual ~DataEntry();
00119 
00120 
00121     // Member Functions
00122 
00123         // Access
00124 
00125             //- Return the name of the entry
00126             const word& name() const;
00127 
00128 
00129         // Evaluation
00130 
00131             //- Return value as a function of (scalar) independent variable
00132             virtual Type value(const scalar x) const = 0;
00133 
00134             //- Integrate between two (scalar) values
00135             virtual Type integrate(const scalar x1, const scalar x2) const = 0;
00136 
00137 
00138     //- Ostream Operator
00139     friend Ostream& operator<< <Type>
00140     (
00141         Ostream&,
00142         const DataEntry<Type>&
00143     );
00144 };
00145 
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 } // End namespace Foam
00150 
00151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00152 
00153 #define makeDataEntry(Type)                                                   \
00154                                                                               \
00155     defineNamedTemplateTypeNameAndDebug(DataEntry<Type>, 0);                  \
00156                                                                               \
00157     defineTemplateRunTimeSelectionTable                                       \
00158     (                                                                         \
00159         DataEntry<Type>,                                                      \
00160         dictionary                                                            \
00161     );
00162 
00163 
00164 #define makeDataEntryType(SS, Type)                                           \
00165                                                                               \
00166     defineNamedTemplateTypeNameAndDebug(SS<Type>, 0);                         \
00167                                                                               \
00168     DataEntry<Type>::adddictionaryConstructorToTable<SS<Type> >               \
00169         add##SS##Type##ConstructorToTable_;
00170 
00171 
00172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00173 
00174 #ifdef NoRepository
00175 #   include "DataEntry.C"
00176 #   include "NewDataEntry.C"
00177 #endif
00178 
00179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00180 
00181 #endif
00182 
00183 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd