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 -------------------------------------------------------------------------------
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 Class
27  Foam::PtrListDictionary
28 
29 Description
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 
35 SourceFiles
36  PtrListDictionary.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef PtrListDictionary_H
41 #define PtrListDictionary_H
42 
43 #include "DictionaryBase.H"
44 #include "PtrList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class PtrListDictionary Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 template<class T>
57 :
58  public DictionaryBase<PtrList<T>, T>
59 {
60 
61 public:
62 
63  // Constructors
64 
65  //- Construct given initial list size
66  PtrListDictionary(const label size);
67 
68  //- Copy construct
70 
71  //- Construct from Istream using given Istream constructor class
72  template<class INew>
73  PtrListDictionary(Istream& is, const INew& inew);
74 
75  //- Construct from Istream
77 
78 
79  // Member functions
80 
81  //- Set element to pointer provided and return old element
82  autoPtr<T> set(const label, const word& key, T*);
83 
84  //- Set element to autoPtr value provided and return old element
85  autoPtr<T> set(const label, const word& key, autoPtr<T>&);
86 
87  //- Set element to tmp value provided and return old element
88  autoPtr<T> set(const label, const word& key, tmp<T>&);
89 
90 
91  // Member operators
92 
93  using PtrList<T>::operator[];
94 
95  //- Find and return entry
96  const T& operator[](const word& key) const
97  {
99  }
100 
101  //- Find and return entry
102  T& operator[](const word& key)
103  {
105  }
106 };
107 
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 } // End namespace Foam
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 #ifdef NoRepository
116  #include "PtrListDictionary.C"
117 #endif
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #endif
122 
123 // ************************************************************************* //
Foam::PtrListDictionary::operator[]
const T & operator[](const word &key) const
Find and return entry.
Definition: PtrListDictionary.H:95
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::PtrListDictionary::PtrListDictionary
PtrListDictionary(const label size)
Construct given initial list size.
Definition: PtrListDictionary.C:33
Foam::PtrListDictionary
Template dictionary class which manages the storage associated with it.
Definition: PtrListDictionary.H:55
Foam::INew
A helper class when constructing from an Istream or dictionary.
Definition: INew.H:51
Foam::PtrListDictionary::set
autoPtr< T > set(const label, const word &key, T *)
Set element to pointer provided and return old element.
Definition: PtrListDictionary.C:67
Foam::DictionaryBase< PtrList< T >, T >::operator
friend Ostream & operator(Ostream &, const DictionaryBase< PtrList< T >, T > &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::PtrListDictionary::operator[]
T & operator[](const word &key)
Find and return entry.
Definition: PtrListDictionary.H:101
dict
dictionary dict
Definition: searchingEngine.H:14
DictionaryBase.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::DictionaryBase
Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it...
Definition: DictionaryBase.H:64
PtrList.H
PtrListDictionary.C