UPtrListDictionary.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023 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::UPtrListDictionary
26 
27 Description
28  Template dictionary class which manages the storage associated with it.
29 
30  It is derived from DictionaryBase instantiated on the UPtrList of <T> to
31  provide ordered indexing in addition to the dictionary lookup.
32 
33 SourceFiles
34  UPtrListDictionary.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef UPtrListDictionary_H
39 #define UPtrListDictionary_H
40 
41 #include "DictionaryBase.H"
42 #include "UPtrList.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 template<class T>
50 class PtrListDictionary;
51 
52 /*---------------------------------------------------------------------------*\
53  Class UPtrListDictionary Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class T>
58 :
59  public DictionaryBase<UPtrList<T>, T>
60 {
61 
62 public:
63 
64  // Constructors
65 
66  //- Construct given initial list size
68 
69  //- Copy constructor
71 
72  //- Copy constructor of PtrListDictionary
74 
75  //- Move constructor
77 
78 
79  // Member Functions
80 
81  //- Is element set
82  inline bool set(const label) const;
83 
84  //- Set element. Return old element (can be nullptr).
85  // No checks on new element
86  inline T* set(const label, const word& key, T*);
87 
88 
89  // Member Operators
90 
91  using UPtrList<T>::operator[];
92 
93  //- Find and return entry
94  const T& operator[](const word& key) const
95  {
96  return *DictionaryBase<UPtrList<T>, T>::operator[](key);
97  }
98 
99  //- Find and return entry
100  T& operator[](const word& key)
101  {
102  return *DictionaryBase<UPtrList<T>, T>::operator[](key);
103  }
104 };
105 
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 } // End namespace Foam
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 #ifdef NoRepository
114  #include "UPtrListDictionary.C"
115 #endif
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 #endif
120 
121 // ************************************************************************* //
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< UPtrList< T >, T > &)
Template dictionary class which manages the storage associated with it.
Template dictionary class which manages the storage associated with it.
bool set(const label) const
Is element set.
const T & operator[](const word &key) const
Find and return entry.
UPtrListDictionary(const label size)
Construct given initial list size.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)