All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ListCompactIO.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::ListCompactIO
26 
27 Description
28  A List of objects of type <T> with input and output using
29  a compact storage. Behaves like List except when binary output in
30  case it writes a CompactListList.
31 
32  Useful for lists of small sublists e.g. faceList, cellList.
33 
34 SourceFiles
35  ListCompactIO.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef ListCompactIO_H
40 #define ListCompactIO_H
41 
42 #include "labelList.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 class Istream;
50 class Ostream;
51 
52 // Forward declaration of friend functions and operators
53 template<class T, class BaseType> class ListCompactIO;
54 
55 template<class T, class BaseType>
57 
58 template<class T, class BaseType> Istream& operator>>
59 (
60  Istream&,
62 );
63 
64 template<class T, class BaseType> Ostream& operator<<
65 (
66  Ostream&,
68 );
69 
70 
71 /*---------------------------------------------------------------------------*\
72  Class ListCompactIO Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 template<class T, class BaseType>
76 class ListCompactIO
77 :
78  public List<T>
79 {
80 protected:
81 
82  // Protected Member Functions
83 
84  //- Has too many elements in it?
85  bool overflows() const;
86 
87  void convertToCompact
88  (
89  labelList& start,
90  List<BaseType>& elems
91  ) const;
92 
94  (
95  const labelList& start,
96  const List<BaseType>& elems
97  );
98 
99 
100 public:
101 
102  // Constructors
103 
104  //- Construct null
105  ListCompactIO();
106 
107  //- Construct from UList
108  ListCompactIO(const UList<T>&);
109 
110  //- Construct from Istream
111  ListCompactIO(Istream&);
112 
113  //- Copy constructor
115 
116  //- Move constructor
118 
119  //- Move constructor from List
121 
122 
123  // Member Operators
124 
127 
128  void operator=(const List<T>&);
129  void operator=(List<T>&&);
130 
131 
132  // IOstream functions
133 
134  friend void writeEntry <T, BaseType>
135  (
136  Ostream& os,
138  );
139 
140 
141  // IOstream Operators
142 
143  //- Read List from Istream, discarding contents of existing List.
144  friend Istream& operator>> <T, BaseType>
145  (
146  Istream&,
148  );
149 
150  // Write List to Ostream.
151  friend Ostream& operator<< <T, BaseType>
152  (
153  Ostream&,
155  );
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #ifdef NoRepository
166  #include "ListCompactIO.C"
167 #endif
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
void convertToCompact(labelList &start, List< BaseType > &elems) const
Definition: ListCompactIO.C:49
ListCompactIO()
Construct null.
void convertFromCompact(const labelList &start, const List< BaseType > &elems)
Definition: ListCompactIO.C:90
A List of objects of type <T> with input and output using a compact storage. Behaves like List except...
Definition: ListCompactIO.H:52
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
bool overflows() const
Has too many elements in it?
Definition: ListCompactIO.C:31
void operator=(const ListCompactIO< T, BaseType > &)
Namespace for OpenFOAM.