FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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::ILList
26 
27 Description
28  Template class for intrusive linked lists.
29 
30 SourceFiles
31  ILList.C
32  ILListIO.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef ILList_H
37 #define ILList_H
38 
39 #include <OpenFOAM/UILList.H>
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 class Istream;
47 class Ostream;
48 
49 // Forward declaration of friend functions and operators
50 
51 template<class LListBase, class T> class ILList;
52 
53 template<class LListBase, class T> Istream& operator>>
54 (
55  Istream&,
56  ILList<LListBase, T>&
57 );
58 
59 
60 /*---------------------------------------------------------------------------*\
61  Class ILList Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template<class LListBase, class T>
65 class ILList
66 :
67  public UILList<LListBase, T>
68 {
69  // Private member functions
70 
71  //- Read from Istream using given Istream constructor class
72  template<class INew>
73  void read(Istream&, const INew&);
74 
75 
76 public:
77 
78  // Constructors
79 
80  //- Null construct
82  {}
83 
84  //- Construct given initial T
85  ILList(T* a)
86  :
87  UILList<LListBase, T>(a)
88  {}
89 
90  //- Construct from Istream
91  ILList(Istream&);
92 
93  //- Construct as copy
95 
96  //- Copy constructor with additional argument for clone
97  template<class CloneArg>
98  ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg)
99  #ifdef __INTEL_COMPILER
100  :
102  {
103  for
104  (
106  lst.begin();
107  iter != lst.end();
108  ++iter
109  )
110  {
111  append(iter().clone(cloneArg).ptr());
112  }
113  }
114  #else
115  ;
116  #endif
117 
118  //- Construct from Istream using given Istream constructor class
119  template<class INew>
120  ILList(Istream&, const INew&);
121 
122 
123  // Destructor
124 
125  ~ILList();
126 
127 
128  // Member Functions
129 
130  // Edit
131 
132  //- Remove the head element specified from the list and delete it
133  bool eraseHead();
134 
135  //- Remove the specified element from the list and delete it
136  bool erase(T* p);
137 
138  //- Clear the contents of the list
139  void clear();
140 
141  //- Transfer the contents of the argument into this List
142  // and annull the argument list.
143  void transfer(ILList<LListBase, T>&);
144 
145 
146  // Member operators
147 
148  void operator=(const ILList<LListBase, T>&);
149 
150 
151  // Istream operator
152 
153  //- Read List from Istream, discarding contents of existing List.
154  friend Istream& operator>> <LListBase, T>
155  (
156  Istream&,
157  ILList<LListBase, T>&
158  );
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #ifdef NoRepository
169 # include <OpenFOAM/ILList.C>
170 #endif
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************ vim: set sw=4 sts=4 et: ************************ //