Keyed.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::Keyed
28 
29 Description
30  A container with an integer key attached to any item.
31 
32  The key can useful for sorting.
33 
34 SourceFiles
35  KeyedI.H
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Keyed_H
40 #define Keyed_H
41 
42 #include "List.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of friend functions and operators
50 
51 template<class T> class Keyed;
52 
53 template<class T> Istream& operator>>(Istream&, Keyed<T>&);
54 template<class T> Ostream& operator<<(Ostream&, const Keyed<T>&);
55 
56 /*---------------------------------------------------------------------------*\
57  Class Keyed Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class T>
61 class Keyed
62 :
63  public T
64 {
65  // Private data
66 
67  label key_;
68 
69 public:
70 
71  // Static Members
72 
73  //- Add labels to a list of values
74  inline static List<Keyed<T>> createList
75  (
76  const UList<T>& lst,
77  const label key=0
78  );
79 
80  //- Add labels to a list of values
81  inline static List<Keyed<T>> createList
82  (
83  const UList<T>& lst,
84  const labelUList& keys
85  );
86 
87 
88  // Constructors
89 
90  //- Construct null
91  inline Keyed();
92 
93  //- Copy construct item, with a key
94  inline Keyed(const T& item, const label key=0);
95 
96  //- Move construct item, with a key
97  inline Keyed(T&& item, const label key=0);
98 
99  //- Construct from Istream
100  inline Keyed(Istream& is);
101 
102 
103  // Member Functions
104 
105  // Access
106 
107  //- Return const access to the integer key
108  inline label key() const;
109 
110  //- Return non-const access to the integer key
111  inline label& key();
112 
113 
114  // IOstream Operators
115 
116  friend Istream& operator>> <T>(Istream&, Keyed<T>&);
117  friend Ostream& operator<< <T>(Ostream&, const Keyed<T>&);
118 };
119 
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 } // End namespace Foam
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #include "KeyedI.H"
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 #endif
132 
133 // ************************************************************************* //
List.H
Foam::Keyed::key
label key() const
Return const access to the integer key.
Definition: KeyedI.H:65
Foam::Keyed
A container with an integer key attached to any item.
Definition: Keyed.H:50
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
KeyedI.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Keyed::Keyed
Keyed()
Construct null.
Definition: KeyedI.H:33
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::Keyed::createList
static List< Keyed< T > > createList(const UList< T > &lst, const label key=0)
Add labels to a list of values.
Definition: KeyedI.H:79
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56