All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ULPtrList.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) 2011-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::ULPtrList
26 
27 Description
28  Template class for non-intrusive linked PtrLists.
29 
30 SourceFiles
31  ULPtrList.C
32  ULPtrListIO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef ULPtrList_H
37 #define ULPtrList_H
38 
39 #include "LList.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of friend functions and operators
47 
48 template<class LListBase, class T> class ULPtrList;
49 
50 template<class LListBase, class T>
51 Ostream& operator<<
52 (
53  Ostream&,
55 );
56 
57 
58 /*---------------------------------------------------------------------------*\
59  Class ULPtrList Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<class LListBase, class T>
63 class ULPtrList
64 :
65  public LList<LListBase, T*>
66 {
67 
68 public:
69 
70  // Forward declaration of STL iterators
71 
72  class iterator;
73  friend class iterator;
74 
76  friend class const_iterator;
77 
78 
79  // Constructors
80 
81  //- Null construct
82  ULPtrList()
83  {}
84 
85  //- Construct given initial T
86  ULPtrList(T* a)
87  :
88  LList<LListBase, T*>(a)
89  {}
90 
91  //- Copy constructor
92  ULPtrList(const ULPtrList&);
93 
94  //- Move constructor
96 
97 
98  // Member Functions
99 
100  // Access
101 
102  //- Return the first entry added
103  T& first()
104  {
105  return *LList<LListBase, T*>::first();
106  }
107 
108  //- Return const access to the first entry added
109  const T& first() const
110  {
111  return *LList<LListBase, T*>::first();
112  }
113 
114  //- Return the last entry added
115  T& last()
116  {
117  return *LList<LListBase, T*>::last();
118  }
119 
120  //- Return const access to the last entry added
121  const T& last() const
122  {
123  return *LList<LListBase, T*>::last();
124  }
125 
126 
127  // Member Operators
128 
129  //- Assignment operator
130  void operator=(const ULPtrList<LListBase, T>&);
131 
132  //- Move assignment operator
134 
135 
136  // STL type definitions
137 
138  //- Type that can be used for storing into ULPtrList::value_type
139  // objects.
140  typedef T& reference;
141 
142  //- Type that can be used for storing into constant
143  // ULPtrList::value_type objects.
144  typedef T& const_reference;
145 
146 
147  // STL iterator
148 
149  typedef typename LListBase::iterator LListBase_iterator;
150 
151  //- An STL-conforming iterator
152  class iterator
153  :
154  public LList<LListBase, T*>::iterator
155  {
156 
157  public:
158 
159  //- Construct from base iterator
160  iterator(LListBase_iterator baseIter)
161  :
162  LList<LListBase, T*>::iterator(baseIter)
163  {}
164 
165 
166  // Member Operators
167 
168  T& operator*()
169  {
171  }
172 
173  T& operator()()
174  {
175  return operator*();
176  }
177  };
178 
179 
180  // STL const_iterator
181 
182  typedef typename LListBase::const_iterator LListBase_const_iterator;
183 
184  //- An STL-conforming const_iterator
185  class const_iterator
186  :
187  public LList<LListBase, T*>::const_iterator
188  {
189 
190  public:
191 
192  //- Construct from base const_iterator
194  :
195  LList<LListBase, T*>::const_iterator(baseIter)
196  {}
197 
198  //- Construct from base iterator
200  :
201  LList<LListBase, T*>::const_iterator(baseIter)
202  {}
203 
204 
205  // Member Operators
206 
207  const T& operator*()
208  {
210  }
211 
212  const T& operator()()
213  {
214  return operator*();
215  }
216  };
217 
218 
219  // IOstream Operators
220 
221  friend Ostream& operator<< <LListBase, T>
222  (
223  Ostream&,
225  );
226 };
227 
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 } // End namespace Foam
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #ifdef NoRepository
236  #include "ULPtrList.C"
237 #endif
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #endif
242 
243 // ************************************************************************* //
const T & operator*()
Definition: LList.H:320
Template class for non-intrusive linked lists.
Definition: LList.H:76
T & first()
Return the first entry added.
Definition: LList.H:139
T & last()
Return the last entry added.
Definition: LList.H:151
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An STL-conforming const_iterator.
Definition: ULPtrList.H:187
const_iterator(LListBase_const_iterator baseIter)
Construct from base const_iterator.
Definition: ULPtrList.H:192
An STL-conforming iterator.
Definition: ULPtrList.H:154
iterator(LListBase_iterator baseIter)
Construct from base iterator.
Definition: ULPtrList.H:159
Template class for non-intrusive linked PtrLists.
Definition: ULPtrList.H:65
LListBase::const_iterator LListBase_const_iterator
Definition: ULPtrList.H:181
void operator=(const ULPtrList< LListBase, T > &)
Assignment operator.
Definition: ULPtrList.C:51
T & first()
Return the first entry added.
Definition: ULPtrList.H:102
T & const_reference
Type that can be used for storing into constant.
Definition: ULPtrList.H:143
T & last()
Return the last entry added.
Definition: ULPtrList.H:114
T & reference
Type that can be used for storing into ULPtrList::value_type.
Definition: ULPtrList.H:139
LListBase::iterator LListBase_iterator
Definition: ULPtrList.H:148
ULPtrList()
Null construct.
Definition: ULPtrList.H:81
Namespace for OpenFOAM.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)