CompactIOList.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 | Copyright (C) 2011-2014 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::CompactIOList
26 
27 Description
28  A List of objects of type <T> with automated input and output using
29  a compact storage. Behaves like IOList 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  CompactIOList.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef CompactIOList_H
40 #define CompactIOList_H
41 
42 #include "IOList.H"
43 #include "regIOobject.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 class Istream;
51 class Ostream;
52 
53 // Forward declaration of friend functions and operators
54 template<class T, class BaseType> class CompactIOList;
55 
56 template<class T, class BaseType> Istream& operator>>
57 (
58  Istream&,
60 );
61 template<class T, class BaseType> Ostream& operator<<
62 (
63  Ostream&,
65 );
66 
67 /*---------------------------------------------------------------------------*\
68  Class CompactIOList Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 template<class T, class BaseType>
72 class CompactIOList
73 :
74  public regIOobject,
75  public List<T>
76 {
77  // Private Member Functions
78 
79  //- Read according to header type
80  void readFromStream();
81 
82  //- Has too many elements in it?
83  bool overflows() const;
84 
85 public:
86 
87  //- Runtime type information
88  TypeName("CompactList");
89 
90 
91  // Constructors
92 
93  //- Construct from IOobject
94  CompactIOList(const IOobject&);
95 
96  //- Construct from IOobject and size of CompactIOList
97  CompactIOList(const IOobject&, const label);
98 
99  //- Construct from IOobject and a List
100  CompactIOList(const IOobject&, const List<T>&);
101 
102  //- Construct by transferring the List contents
103  CompactIOList(const IOobject&, const Xfer<List<T> >&);
104 
105 
106  // Destructor
107 
108  virtual ~CompactIOList();
109 
110 
111  // Member functions
112 
113  virtual bool writeObject
114  (
118  ) const;
119 
120  virtual bool writeData(Ostream&) const;
121 
122 
123  // Member operators
124 
126 
127  void operator=(const List<T>&);
128 
129 
130  // IOstream operators
131 
132  //- Read List from Istream, discarding contents of existing List.
133  friend Istream& operator>> <T, BaseType>
134  (
135  Istream&,
137  );
138 
139  // Write List to Ostream.
140  friend Ostream& operator<< <T, BaseType>
141  (
142  Ostream&,
144  );
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #ifdef NoRepository
155 # include "CompactIOList.C"
156 #endif
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
regIOobject.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::CompactIOList::overflows
bool overflows() const
Has too many elements in it?
Definition: CompactIOList.C:59
Foam::CompactIOList::writeObject
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType) const
Definition: CompactIOList.C:175
Foam::CompactIOList::CompactIOList
CompactIOList(const IOobject &)
Construct from IOobject.
Foam::IOstream::compressionType
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
Foam::Xfer
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
IOList.H
Foam::IOstream::versionNumber
Version number type.
Definition: IOstream.H:96
Foam::CompactIOList::readFromStream
void readFromStream()
Read according to header type.
Definition: CompactIOList.C:32
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::CompactIOList
A List of objects of type <T> with automated input and output using a compact storage....
Definition: CompactIOList.H:53
Foam::CompactIOList::writeData
virtual bool writeData(Ostream &) const
Definition: CompactIOList.C:222
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
CompactIOList.C
Foam::CompactIOList::operator=
void operator=(const CompactIOList< T, BaseType > &)
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
Foam::List
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
Foam::CompactIOList::~CompactIOList
virtual ~CompactIOList()
Definition: CompactIOList.C:166
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::CompactIOList::TypeName
TypeName("CompactList")
Runtime type information.
Foam::IOstream::streamFormat
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86