PtrListDictionary.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "PtrListDictionary.H"
29
30// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31
32template<class T>
34:
35 DictionaryBase<PtrList<T>, T>(2*size)
36{
38}
39
40
41template<class T>
43:
45{}
46
47
48template<class T>
49template<class INew>
51:
52 DictionaryBase<PtrList<T>, T>(is, iNew)
53{}
54
55
56template<class T>
58:
60{}
61
62
63// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65template<class T>
68 const label i,
69 const word& key,
70 T* ptr
72{
73 if (!DictionaryBase<PtrList<T>, T>::hashedTs_.insert(key, ptr))
74 {
76 << "Cannot insert with key '" << key << "' into hash-table"
77 << abort(FatalError);
78 }
79 return PtrList<T>::set(i, ptr);
81
82
83template<class T>
85(
86 const label i,
87 const word& key,
88 autoPtr<T>& aptr
89)
90{
91 T* ptr = aptr.ptr();
92 if (!DictionaryBase<PtrList<T>, T>::hashedTs_.insert(key, ptr))
93 {
95 << "Cannot insert with key '" << key << "' into hash-table"
96 << abort(FatalError);
97 }
98 return PtrList<T>::set(i, ptr);
99}
100
101
102template<class T>
104(
105 const label i,
106 const word& key,
107 tmp<T>& t
108)
109{
110 T* ptr = t.ptr();
111 if (!DictionaryBase<PtrList<T>, T>::hashedTs_.insert(key, ptr))
112 {
114 << "Cannot insert with key '" << key << "' into hash-table"
115 << abort(FatalError);
116 }
117 return PtrList<T>::set(i, ptr);
118}
119
120
121// ************************************************************************* //
Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it...
virtual bool resize()
Resize the ODE solver.
Definition: Euler.C:53
A helper class when constructing from an Istream or dictionary.
Definition: INew.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Template dictionary class which manages the storage associated with it.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
T * ptr() noexcept
Same as release().
Definition: autoPtr.H:172
A class for managing temporary objects.
Definition: tmp.H:65
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
Definition: tmpI.H:255
bool set() const
Are all the vector set.
Definition: triadI.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
const volScalarField & T
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
dictionary dict