initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / containers / LinkedLists / accessTypes / ILList / ILList.H
blob20635fa53f944bedcaa4f240d05657a09782f2df
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::ILList
28 Description
29     Template class for intrusive linked lists.
31 SourceFiles
32     ILList.C
33     ILListIO.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef ILList_H
38 #define ILList_H
40 #include "UILList.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 class Istream;
48 class Ostream;
50 // Forward declaration of friend functions and operators
52 template<class LListBase, class T> class ILList;
54 template<class LListBase, class T> Istream& operator>>
56     Istream&,
57     ILList<LListBase, T>&
61 /*---------------------------------------------------------------------------*\
62                            Class ILList Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class LListBase, class T>
66 class ILList
68     public UILList<LListBase, T>
70     // Private member functions
72         //- Read from Istream using given Istream constructor class
73         template<class INew>
74         void read(Istream&, const INew&);
77 public:
79     // Constructors
81         //- Null construct
82         ILList()
83         {}
85         //- Construct given initial T
86         ILList(T* a)
87         :
88             UILList<LListBase, T>(a)
89         {}
91         //- Construct from Istream
92         ILList(Istream&);
94         //- Construct as copy
95         ILList(const ILList<LListBase, T>&);
97         //- Copy constructor with additional argument for clone
98         template<class CloneArg>
99         ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg)
100         #ifdef __INTEL_COMPILER
101         :
102             UILList<LListBase, T>()
103         {
104             for
105             (
106                 typename UILList<LListBase, T>::const_iterator iter =
107                     lst.begin();
108                 iter != lst.end();
109                 ++iter
110             )
111             {
112                 append(iter().clone(cloneArg).ptr());
113             }
114         }
115         #else
116         ;
117         #endif
119         //- Construct from Istream using given Istream constructor class
120         template<class INew>
121         ILList(Istream&, const INew&);
124     // Destructor
126         ~ILList();
129     // Member Functions
131         // Edit
133             //- Remove the head element specified from the list and delete it
134             bool eraseHead();
136             //- Remove the specified element from the list and delete it
137             bool erase(T* p);
139             //- Clear the contents of the list
140             void clear();
142             //- Transfer the contents of the argument into this List
143             //  and annull the argument list.
144             void transfer(ILList<LListBase, T>&);
147     // Member operators
149         void operator=(const ILList<LListBase, T>&);
152     // Istream operator
154         //- Read List from Istream, discarding contents of existing List.
155         friend Istream& operator>> <LListBase, T>
156         (
157             Istream&,
158             ILList<LListBase, T>&
159         );
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 } // End namespace Foam
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 #ifdef NoRepository
170 #   include "ILList.C"
171 #endif
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 #endif
177 // ************************************************************************* //