refLabelledPoint.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  refLabelledPoint
26 
27 Description
28  A class containing the label of the object it is associated to and
29  a labelledPoint
30 
31 SourceFiles
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef refLabelledPoint_H
36 #define refLabelledPoint_H
37 
38 #include "labelledPoint.H"
39 #include "contiguous.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class refLabelledPoint Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class refLabelledPoint
51 {
52  // Private data
53  //- label of the object it is associated to
55 
56  //- point to be transferred
58 
59  public:
60 
61  // Constructors
62  //- Null construct
64  :
65  objectLabel_(-1),
66  p_()
67  {}
68 
69  //- Construct from label and labelledPoint
70  refLabelledPoint(const label pl, const labelledPoint& p)
71  :
72  objectLabel_(pl),
73  p_(p)
74  {}
75 
76  // Destructor
78  {}
79 
80  // Member functions
81  //- return label of the object it is associated to
82  inline label objectLabel() const
83  {
84  return objectLabel_;
85  }
86 
87  //- return labelledPoint
88  inline const labelledPoint& lPoint() const
89  {
90  return p_;
91  }
92 
93  // Member operators
94 
95  inline void operator=(const refLabelledPoint& lp)
96  {
98  p_ = lp.p_;
99  }
100 
101  inline bool operator==(const refLabelledPoint& lp) const
102  {
103  if( objectLabel_ == lp.objectLabel_ )
104  return true;
105 
106  return false;
107  }
108 
109  inline bool operator!=(const refLabelledPoint& lp) const
110  {
111  return !this->operator==(lp);
112  }
113 
114  // Friend operators
115  friend Ostream& operator<<(Ostream& os, const refLabelledPoint& lp)
116  {
117  os << token::BEGIN_LIST;
118  os << lp.objectLabel_ << token::SPACE;
119  os << lp.p_ << token::END_LIST;
120 
121  // Check state of Ostream
122  os.check("operator<<(Ostream&, const refLabelledPoint&");
123 
124  return os;
125  }
126 
127  friend Istream& operator>>(Istream& is, refLabelledPoint& lp)
128  {
129  // Read beginning of refLabelledPoint
130  is.readBegin("refLabelledPoint");
131 
132  is >> lp.objectLabel_;
133  is >> lp.p_;
134 
135  // Read end of refLabelledPoint
136  is.readEnd("refLabelledPoint");
137 
138  // Check state of Istream
139  is.check("operator>>(Istream&, refLabelledPoint");
140 
141  return is;
142  }
143 };
144 
145 //- Specify data associated with refLabelledPoint type is contiguous
146 template<>
147 inline bool contiguous<refLabelledPoint>() {return true;}
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #endif
156 
157 // ************************************************************************* //
Foam::refLabelledPoint::refLabelledPoint
refLabelledPoint(const label pl, const labelledPoint &p)
Construct from label and labelledPoint.
Definition: refLabelledPoint.H:69
Foam::refLabelledPoint::p_
labelledPoint p_
point to be transferred
Definition: refLabelledPoint.H:56
Foam::Istream::readEnd
Istream & readEnd(const char *funcName)
Definition: Istream.C:105
p
p
Definition: pEqn.H:62
Foam::refLabelledPoint::operator!=
bool operator!=(const refLabelledPoint &lp) const
Definition: refLabelledPoint.H:108
Foam::refLabelledPoint::refLabelledPoint
refLabelledPoint()
Null construct.
Definition: refLabelledPoint.H:62
Foam::refLabelledPoint
Definition: refLabelledPoint.H:49
Foam::contiguous< refLabelledPoint >
bool contiguous< refLabelledPoint >()
Specify data associated with refLabelledPoint type is contiguous.
Definition: refLabelledPoint.H:146
Foam::refLabelledPoint::objectLabel_
label objectLabel_
label of the object it is associated to
Definition: refLabelledPoint.H:53
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::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
labelledPoint.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::refLabelledPoint::objectLabel
label objectLabel() const
return label of the object it is associated to
Definition: refLabelledPoint.H:81
Foam::refLabelledPoint::operator>>
friend Istream & operator>>(Istream &is, refLabelledPoint &lp)
Definition: refLabelledPoint.H:126
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
Foam::labelledPoint
Definition: labelledPoint.H:50
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::refLabelledPoint::operator<<
friend Ostream & operator<<(Ostream &os, const refLabelledPoint &lp)
Definition: refLabelledPoint.H:114
Foam::refLabelledPoint::operator==
bool operator==(const refLabelledPoint &lp) const
Definition: refLabelledPoint.H:100
Foam::refLabelledPoint::~refLabelledPoint
~refLabelledPoint()
Definition: refLabelledPoint.H:76
Foam::refLabelledPoint::operator=
void operator=(const refLabelledPoint &lp)
Definition: refLabelledPoint.H:94
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::refLabelledPoint::lPoint
const labelledPoint & lPoint() const
return labelledPoint
Definition: refLabelledPoint.H:87
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
Foam::token::SPACE
@ SPACE
Definition: token.H:95