objectMapI.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 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 // ************************************************************************* //
Foam::objectMap::index
label & index()
Return object index.
Definition: objectMapI.H:68
Foam::Istream::readEnd
Istream & readEnd(const char *funcName)
Definition: Istream.C:105
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
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::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::objectMap::objectMap
objectMap()
Null constructor for lists.
Definition: objectMapI.H:37
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::operator!=
bool operator!=(const particle &, const particle &)
Definition: particle.C:147
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Foam::objectMap
An objectMap is a pair of labels defining the mapping of an object from another object,...
Definition: objectMap.H:58
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::objectMap::masterObjects_
labelList masterObjects_
Master object index.
Definition: objectMap.H:66
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
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::objectMap::index_
label index_
Object index.
Definition: objectMap.H:63
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::objectMap::masterObjects
labelList & masterObjects()
Return master object index.
Definition: objectMapI.H:80
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Istream::readBegin
Istream & readBegin(const char *funcName)
Definition: Istream.C:88
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
Foam::token::SPACE
@ SPACE
Definition: token.H:95