PtrListDictionary.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015-2016 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
26Class
27 Foam::PtrListDictionary
28
29Description
30 Template dictionary class which manages the storage associated with it.
31
32 It is derived from DictionaryBase instantiated on the memory managed PtrList
33 of <T> to provide ordered indexing in addition to the dictionary lookup.
34
35SourceFiles
36 PtrListDictionary.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef Foam_PtrListDictionary_H
41#define Foam_PtrListDictionary_H
42
43#include "DictionaryBase.H"
44#include "PtrList.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51/*---------------------------------------------------------------------------*\
52 Class PtrListDictionary Declaration
53\*---------------------------------------------------------------------------*/
54
55template<class T>
57:
58 public DictionaryBase<PtrList<T>, T>
59{
60public:
61
62 // Constructors
63
64 //- Construct given initial list size
65 explicit PtrListDictionary(const label size);
66
67 //- Copy construct
69
70 //- Construct from Istream using given Istream constructor class
71 template<class INew>
72 PtrListDictionary(Istream& is, const INew& inew);
73
74 //- Construct from Istream
75 explicit PtrListDictionary(Istream& is);
76
77
78 // Member functions
79
80 //- Set element to pointer provided and return old element
81 autoPtr<T> set(const label i, const word& key, T* ptr);
82
83 //- Set element to autoPtr value provided and return old element
84 autoPtr<T> set(const label i, const word& key, autoPtr<T>& aptr);
85
86 //- Set element to tmp value provided and return old element
87 autoPtr<T> set(const label i, const word& key, tmp<T>& t);
88
89
90 // Member operators
91
92 using PtrList<T>::operator[];
93
94 //- Find and return entry
95 const T& operator[](const word& key) const
96 {
98 }
99
100 //- Find and return entry
101 T& operator[](const word& key)
102 {
103 return *DictionaryBase<PtrList<T>, T>::operator[](key);
104 }
105};
106
107
108// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109
110} // End namespace Foam
111
112// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113
114#ifdef NoRepository
115 #include "PtrListDictionary.C"
116#endif
117
118// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119
120#endif
121
122// ************************************************************************* //
Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it...
friend Ostream & operator(Ostream &, const DictionaryBase< PtrList< T >, T > &)
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.
autoPtr< T > set(const label i, const word &key, T *ptr)
Set element to pointer provided and return old element.
T & operator[](const word &key)
Find and return entry.
const T & operator[](const word &key) const
Find and return entry.
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
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
const volScalarField & T
Namespace for OpenFOAM.
dictionary dict