INew.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) 2011 OpenFOAM Foundation
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::INew
26 
27 Description
28  A helper class when constructing from an Istream or dictionary
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef INew_H
33 #define INew_H
34 
35 #include "autoPtr.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 // Forward declaration of classes
43 class Istream;
44 
45 /*---------------------------------------------------------------------------*\
46  Class INew Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 template<class T>
50 class INew
51 {
52 
53 public:
54 
55  //- Construct null
56  INew()
57  {}
58 
59  //- Construct from Istream
60  autoPtr<T> operator()(Istream& is) const
61  {
62  return T::New(is);
63  }
64 
65  //- Construct from word and Istream
66  autoPtr<T> operator()(const word&, Istream& is) const
67  {
68  return T::New(is);
69  }
70 
71  //- Construct from dictionary
72  autoPtr<T> operator()(const dictionary& dict) const
73  {
74  return T::New(dict);
75  }
76 
77  //- Construct from word and dictionary
78  autoPtr<T> operator()(const word&, const dictionary& dict) const
79  {
80  return T::New(dict);
81  }
82 };
83 
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 } // End namespace Foam
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 #endif
92 
93 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
INew()
Construct null.
Definition: INew.H:55
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
autoPtr< T > operator()(Istream &is) const
Construct from Istream.
Definition: INew.H:59
A class for handling words, derived from string.
Definition: word.H:59
A helper class when constructing from an Istream or dictionary.
Definition: INew.H:49
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Namespace for OpenFOAM.