|
|
|
Keyed.HGo 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-2009 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 the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 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, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 Foam::Keyed 00027 00028 Description 00029 A container with an integer key attached to any item. 00030 00031 The key can useful for sorting. 00032 00033 SourceFiles 00034 KeyedI.H 00035 00036 \*---------------------------------------------------------------------------*/ 00037 00038 #ifndef Keyed_H 00039 #define Keyed_H 00040 00041 #include "List.H" 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 // Forward declaration of friend functions and operators 00049 00050 template<class T> class Keyed; 00051 00052 template<class T> Istream& operator>>(Istream&, Keyed<T>&); 00053 template<class T> Ostream& operator<<(Ostream&, const Keyed<T>&); 00054 00055 /*---------------------------------------------------------------------------*\ 00056 Class Keyed Declaration 00057 \*---------------------------------------------------------------------------*/ 00058 00059 template<class T> 00060 class Keyed 00061 : 00062 public T 00063 { 00064 // Private data 00065 00066 label key_; 00067 00068 public: 00069 00070 // Static Members 00071 00072 //- Add labels to a list of values 00073 inline static List<Keyed<T> > createList 00074 ( 00075 const List<T>&, 00076 const label key=0 00077 ); 00078 00079 //- Add labels to a list of values 00080 inline static List<Keyed<T> > createList 00081 ( 00082 const List<T>&, 00083 const List<label>& keys 00084 ); 00085 00086 00087 // Constructors 00088 00089 //- Construct null 00090 inline Keyed(); 00091 00092 //- Construct as a copy of item, with a key 00093 inline Keyed(const T& item, const label key=0); 00094 00095 //- Construct by transferring the item, with a key 00096 inline Keyed(const Xfer<T>& item, const label key=0); 00097 00098 //- Construct from Istream 00099 inline Keyed(Istream&); 00100 00101 00102 // Member Functions 00103 00104 // Access 00105 00106 //- Return const access to the integer key 00107 inline label key() const; 00108 00109 //- Return non-const access to the integer key 00110 inline label& key(); 00111 00112 00113 // IOstream Operators 00114 00115 friend Istream& operator>> <T>(Istream&, Keyed<T>&); 00116 friend Ostream& operator<< <T>(Ostream&, const Keyed<T>&); 00117 }; 00118 00119 00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00121 00122 } // End namespace Foam 00123 00124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00125 00126 #include "KeyedI.H" 00127 00128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00129 00130 #endif 00131 00132 // ************************************************************************* // |