FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

ILList.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::ILList
00026 
00027 Description
00028     Template class for intrusive linked lists.
00029 
00030 SourceFiles
00031     ILList.C
00032     ILListIO.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef ILList_H
00037 #define ILList_H
00038 
00039 #include <OpenFOAM/UILList.H>
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 class Istream;
00047 class Ostream;
00048 
00049 // Forward declaration of friend functions and operators
00050 
00051 template<class LListBase, class T> class ILList;
00052 
00053 template<class LListBase, class T> Istream& operator>>
00054 (
00055     Istream&,
00056     ILList<LListBase, T>&
00057 );
00058 
00059 
00060 /*---------------------------------------------------------------------------*\
00061                            Class ILList Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 template<class LListBase, class T>
00065 class ILList
00066 :
00067     public UILList<LListBase, T>
00068 {
00069     // Private member functions
00070 
00071         //- Read from Istream using given Istream constructor class
00072         template<class INew>
00073         void read(Istream&, const INew&);
00074 
00075 
00076 public:
00077 
00078     // Constructors
00079 
00080         //- Null construct
00081         ILList()
00082         {}
00083 
00084         //- Construct given initial T
00085         ILList(T* a)
00086         :
00087             UILList<LListBase, T>(a)
00088         {}
00089 
00090         //- Construct from Istream
00091         ILList(Istream&);
00092 
00093         //- Construct as copy
00094         ILList(const ILList<LListBase, T>&);
00095 
00096         //- Copy constructor with additional argument for clone
00097         template<class CloneArg>
00098         ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg)
00099         #ifdef __INTEL_COMPILER
00100         :
00101             UILList<LListBase, T>()
00102         {
00103             for
00104             (
00105                 typename UILList<LListBase, T>::const_iterator iter =
00106                     lst.begin();
00107                 iter != lst.end();
00108                 ++iter
00109             )
00110             {
00111                 this->append(iter().clone(cloneArg).ptr());
00112             }
00113         }
00114         #else
00115         ;
00116         #endif
00117 
00118         //- Construct from Istream using given Istream constructor class
00119         template<class INew>
00120         ILList(Istream&, const INew&);
00121 
00122 
00123     // Destructor
00124 
00125         ~ILList();
00126 
00127 
00128     // Member Functions
00129 
00130         // Edit
00131 
00132             //- Remove the head element specified from the list and delete it
00133             bool eraseHead();
00134 
00135             //- Remove the specified element from the list and delete it
00136             bool erase(T* p);
00137 
00138             //- Clear the contents of the list
00139             void clear();
00140 
00141             //- Transfer the contents of the argument into this List
00142             //  and annull the argument list.
00143             void transfer(ILList<LListBase, T>&);
00144 
00145 
00146     // Member operators
00147 
00148         void operator=(const ILList<LListBase, T>&);
00149 
00150 
00151     // Istream operator
00152 
00153         //- Read List from Istream, discarding contents of existing List.
00154         friend Istream& operator>> <LListBase, T>
00155         (
00156             Istream&,
00157             ILList<LListBase, T>&
00158         );
00159 };
00160 
00161 
00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00163 
00164 } // End namespace Foam
00165 
00166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00167 
00168 #ifdef NoRepository
00169 #   include <OpenFOAM/ILList.C>
00170 #endif
00171 
00172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00173 
00174 #endif
00175 
00176 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines