objectMapI.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) 2011-2022 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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "IOstreams.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
38 :
39  index_(-1),
40  masterObjects_(0)
41 {}
42 
43 
44 inline objectMap::objectMap(const label index, const labelList& master)
45 :
46  index_(index),
47  masterObjects_(master)
48 {}
49 
50 
52 {
53  // Read beginning of objectMap
54  is.readBegin("objectMap");
55 
56  is >> index_ >> static_cast<labelList&>(masterObjects_);
57 
58  // Read master of objectMap
59  is.readEnd("objectMap");
60 
61  // Check state of Istream
62  is.check("objectMap::objectMap(Istream&)");
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
69 {
70  return index_;
71 }
72 
73 
74 inline label objectMap::index() const
75 {
76  return index_;
77 }
78 
79 
81 {
82  return masterObjects_;
83 }
84 
85 
86 inline const labelList& objectMap::masterObjects() const
87 {
88  return masterObjects_;
89 }
90 
91 
92 // * * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * //
93 
94 inline bool operator==(const objectMap& a, const objectMap& b)
95 {
96  return
97  (
98  (a.index_ == b.index_) && (a.masterObjects_ == b.masterObjects_)
99  );
100 }
101 
102 
103 inline bool operator!=(const objectMap& a, const objectMap& b)
104 {
105  return (!(a == b));
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
110 
111 inline Ostream& operator<<(Ostream& os, const objectMap& a)
112 {
113  os << token::BEGIN_LIST
114  << a.index_ << token::SPACE
115  << a.masterObjects_
116  << token::END_LIST;
117 
118  // Check state of Ostream
119  os.check("Ostream& operator<<(Ostream&, const objectMap&)");
120 
121  return os;
122 }
123 
124 
126 {
127  is.readBegin("objectMap");
128  is >> a.index_ >> a.masterObjects_;
129  is.readEnd("objectMap");
130 
131  // Check state of Istream
132  is.check("Istream& operator>>(Istream&, objectMap&)");
133 
134  return is;
135 }
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // Master namespace Foam
141 
142 // ************************************************************************* //
Istream & readBegin(const char *funcName)
Definition: Istream.C:86
friend bool operator!=(const objectMap &a, const objectMap &b)
Definition: objectMapI.H:103
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Definition: createFields.H:27
friend Ostream & operator<<(Ostream &, const objectMap &)
Definition: objectMapI.H:111
An objectMap is a pair of labels defining the mapping of an object from another object, e.g. a cell mapped from a point.
Definition: objectMap.H:58
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
objectMap()
Null constructor for lists.
Definition: objectMapI.H:37
Istream & readEnd(const char *funcName)
Definition: Istream.C:103
friend Istream & operator>>(Istream &, objectMap &)
Definition: objectMapI.H:125
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
labelList & masterObjects()
Return master object index.
Definition: objectMapI.H:80
friend bool operator==(const objectMap &a, const objectMap &b)
Definition: objectMapI.H:94
label & index()
Return object index.
Definition: objectMapI.H:68
Namespace for OpenFOAM.