PtrMap.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::PtrMap
29 
30 Description
31  A HashTable of pointers to objects of type <T> with a label key.
32 
33 See also
34  Map, HashPtrTable
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_PtrMap_H
39 #define Foam_PtrMap_H
40 
41 #include "HashPtrTable.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class PtrMap Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class T>
53 class PtrMap
54 :
55  public HashPtrTable<T, label, Hash<label>>
56 {
57 public:
58 
59  //- The template instance used for this PtrMap
61 
62  //- The template instance used for the parent HashTable
64 
65 
66  // Constructors
67 
68  //- Default construct: empty without allocation (capacity=0)
69  PtrMap() noexcept = default;
70 
71  //- Construct empty without allocation (capacity=0)
72  explicit PtrMap(const Foam::zero) noexcept
73  :
75  {}
76 
77  //- Construct empty with given initial table capacity
78  explicit PtrMap(const label initialCapacity)
79  :
80  parent_type(initialCapacity)
81  {}
82 
83  //- Construct from Istream (with default initial table capacity)
84  PtrMap(Istream& is)
85  :
86  parent_type(is)
87  {}
88 
89  //- Copy construct
90  PtrMap(const this_type& map)
91  :
92  parent_type(map)
93  {}
94 
95  //- Move construct
97  :
98  parent_type(std::move(map))
99  {}
100 
101 
102  // Member Operators
103 
104  //- Copy assignment
105  void operator=(const this_type& rhs)
106  {
108  }
109 
110  //- Move assignment
111  void operator=(this_type&& rhs)
112  {
113  parent_type::operator=(std::move(rhs));
114  }
115 };
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 } // End namespace Foam
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #endif
125 
126 // ************************************************************************* //
void operator=(const this_type &rhs)
Copy assignment.
Definition: PtrMap.H:116
PtrMap() noexcept=default
Default construct: empty without allocation (capacity=0)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
HashPtrTable< T, label, Hash< label > > parent_type
The template instance used for the parent HashTable.
Definition: PtrMap.H:60
A HashTable of pointers to objects of type <T> with a label key.
Definition: HashTableFwd.H:42
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers...
Definition: HashPtrTable.H:51
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
const direction noexcept
Definition: Scalar.H:258
void operator=(const this_type &rhs)
Copy assignment.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
PtrMap< T > this_type
The template instance used for this PtrMap.
Definition: PtrMap.H:55
Namespace for OpenFOAM.