ILList.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-2022 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::ILList
29 
30 Description
31  Template class for intrusive linked lists.
32 
33 SourceFiles
34  ILList.C
35  ILListIO.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_ILList_H
40 #define Foam_ILList_H
41 
42 #include "UILList.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 template<class LListBase, class T> class ILList;
51 
52 template<class LListBase, class T> Istream& operator>>
53 (
54  Istream& is,
56 );
57 
58 
59 /*---------------------------------------------------------------------------*\
60  Class ILList Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class LListBase, class T>
64 class ILList
65 :
66  public UILList<LListBase, T>
67 {
68  // Private Member Functions
69 
70  //- Read from Istream using given Istream constructor class
71  template<class INew>
72  void readIstream(Istream& is, const INew& inew);
73 
74 
75 public:
76 
77  // Constructors
78 
79  //- Default construct
80  ILList() = default;
81 
82  //- Construct and add initial item pointer
83  explicit ILList(T* item)
84  :
85  UILList<LListBase, T>(item)
86  {}
87 
88  //- Construct from Istream
89  explicit ILList(Istream& is);
90 
91  //- Copy construct using the 'clone()' method for each element
92  ILList(const ILList<LListBase, T>& lst);
93 
94  //- Move construct
96 
97  //- Copy constructor with additional argument for clone 'clone()'
98  template<class CloneArg>
99  ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg);
100 
101  //- Construct from Istream using given Istream constructor class
102  template<class INew>
103  ILList(Istream& is, const INew& inew);
104 
105 
106  //- Destructor. Calls clear()
107  ~ILList();
108 
109 
110  // Member Functions
111 
112  //- Clear the contents of the list
113  void clear();
114 
115  //- Remove first element(s) from the list (deletes pointers)
116  void pop_front(label n = 1);
117 
118  //- Remove the specified element from the list and delete it
119  bool erase(T* item);
120 
121  //- Transfer the contents of the argument into this List
122  //- and annul the argument list.
123  void transfer(ILList<LListBase, T>& lst);
124 
125 
126  // Member Operators
127 
128  //- Copy assignment using the 'clone()' method for each element
129  void operator=(const ILList<LListBase, T>& lst);
130 
131  //- Move assignment
132  void operator=(ILList<LListBase, T>&& lst);
133 
134 
135  // Istream Operator
136 
137  //- Read from Istream, discarding existing contents.
138  friend Istream& operator>> <LListBase, T>
139  (
140  Istream& is,
142  );
143 };
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace Foam
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #ifdef NoRepository
153  #include "ILList.C"
154  #include "ILListIO.C"
155 #endif
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
Template class for intrusive linked lists.
Definition: ILList.H:45
Template class for intrusive linked lists.
Definition: UILList.H:47
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void transfer(ILList< LListBase, T > &lst)
Transfer the contents of the argument into this List and annul the argument list. ...
Definition: ILList.C:110
void pop_front(label n=1)
Remove first element(s) from the list (deletes pointers)
Definition: ILList.C:76
void clear()
Clear the contents of the list.
Definition: ILList.C:93
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool erase(T *item)
Remove the specified element from the list and delete it.
Definition: ILList.C:101
ILList()=default
Default construct.
A helper class when constructing from an Istream or dictionary.
Definition: INew.H:46
label n
~ILList()
Destructor. Calls clear()
Definition: ILList.C:67
void operator=(const ILList< LListBase, T > &lst)
Copy assignment using the &#39;clone()&#39; method for each element.
Definition: ILList.C:120
Namespace for OpenFOAM.