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 -------------------------------------------------------------------------------
10 License
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 
32 template<class T>
34 :
36 {
37  PtrList<T>::resize(size);
38 }
39 
40 
41 template<class T>
43 :
45 {}
46 
47 
48 template<class T>
49 template<class INew>
51 :
52  DictionaryBase<PtrList<T>, T>(is, iNew)
53 {}
54 
55 
56 template<class T>
58 :
59  DictionaryBase<PtrList<T>, T>(is)
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 template<class T>
67 (
68  const label i,
69  const word& key,
70  T* ptr
71 )
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);
80 }
81 
82 
83 template<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 
102 template<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 // ************************************************************************* //
dictionary dict
PtrListDictionary(const label size)
Construct given initial list size.
Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it...
patchWriters resize(patchIds.size())
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign &#39;true&#39;).
Definition: BitOps.C:30
Template dictionary class which manages the storage associated with it.
A class for handling words, derived from Foam::string.
Definition: word.H:63
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const volScalarField & T
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
A helper class when constructing from an Istream or dictionary.
Definition: INew.H:46
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
autoPtr< T > set(const label i, const word &key, T *ptr)
Set element to pointer provided and return old element.