initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / containers / Identifiers / Keyed / Keyed.H
blob0a5745cc8f6f280ef5a110a53151a6e5e93cb4b7
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::Keyed
28 Description
29     A container with an integer key attached to any item.
31     The key can useful for sorting.
33 SourceFiles
34     KeyedI.H
36 \*---------------------------------------------------------------------------*/
38 #ifndef Keyed_H
39 #define Keyed_H
41 #include "List.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 // Forward declaration of friend functions and operators
50 template<class T> class Keyed;
52 template<class T> Istream& operator>>(Istream&, Keyed<T>&);
53 template<class T> Ostream& operator<<(Ostream&, const Keyed<T>&);
55 /*---------------------------------------------------------------------------*\
56                        Class Keyed Declaration
57 \*---------------------------------------------------------------------------*/
59 template<class T>
60 class Keyed
62     public T
64     // Private data
66         label key_;
68 public:
70     // Static Members
72         //- Add labels to a list of values
73         inline static List<Keyed<T> > createList
74         (
75             const List<T>&,
76             const label key=0
77         );
79         //- Add labels to a list of values
80         inline static List<Keyed<T> > createList
81         (
82             const List<T>&,
83             const List<label>& keys
84         );
87     // Constructors
89         //- Construct null
90         inline Keyed();
92         //- Construct as a copy of item, with a key
93         inline Keyed(const T& item, const label key=0);
95         //- Construct by transferring the item, with a key
96         inline Keyed(const Xfer<T>& item, const label key=0);
98         //- Construct from Istream
99         inline Keyed(Istream&);
102     // Member Functions
104         // Access
106             //- Return const access to the integer key
107             inline label key() const;
109             //- Return non-const access to the integer key
110             inline label& key();
113     // IOstream Operators
115         friend Istream& operator>> <T>(Istream&, Keyed<T>&);
116         friend Ostream& operator<< <T>(Ostream&, const Keyed<T>&);
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 } // End namespace Foam
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 #include "KeyedI.H"
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 #endif
132 // ************************************************************************* //