Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / helperClasses / parallelHelpers / labelledPoint / refLabelledPoint.H
blobee0a2d037c191522995a4efd53fda7f43d5a8222
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.
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.
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.
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/>.
24 Class
25     refLabelledPoint
27 Description
28     A class containing the label of the object it is associated to and
29     a labelledPoint
31 SourceFiles
33 \*---------------------------------------------------------------------------*/
35 #ifndef refLabelledPoint_H
36 #define refLabelledPoint_H
38 #include "labelledPoint.H"
39 #include "contiguous.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 /*---------------------------------------------------------------------------*\
47                            Class refLabelledPoint Declaration
48 \*---------------------------------------------------------------------------*/
50 class refLabelledPoint
52     // Private data
53         //- label of the object it is associated to
54         label objectLabel_;
56         //- point to be transferred
57         labelledPoint p_;
59     public:
61     // Constructors
62         //- Null construct
63         refLabelledPoint()
64         :
65             objectLabel_(-1),
66             p_()
67         {}
69         //- Construct from label and labelledPoint
70         refLabelledPoint(const label pl, const labelledPoint& p)
71         :
72             objectLabel_(pl),
73             p_(p)
74         {}
76     // Destructor
77         ~refLabelledPoint()
78         {}
80     // Member functions
81         //- return label of the object it is associated to
82         inline label objectLabel() const
83         {
84             return objectLabel_;
85         }
87         //- return labelledPoint
88         inline const labelledPoint& lPoint() const
89         {
90             return p_;
91         }
93     // Member operators
95         inline void operator=(const refLabelledPoint& lp)
96         {
97             objectLabel_ = lp.objectLabel_;
98             p_ = lp.p_;
99         }
101         inline bool operator==(const refLabelledPoint& lp) const
102         {
103             if( objectLabel_ == lp.objectLabel_ )
104                 return true;
106             return false;
107         }
109         inline bool operator!=(const refLabelledPoint& lp) const
110         {
111             return !this->operator==(lp);
112         }
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;
121             // Check state of Ostream
122             os.check("operator<<(Ostream&, const refLabelledPoint&");
124             return os;
125         }
127         friend Istream& operator>>(Istream& is, refLabelledPoint& lp)
128         {
129             // Read beginning of refLabelledPoint
130             is.readBegin("refLabelledPoint");
132             is >> lp.objectLabel_;
133             is >> lp.p_;
135             // Read end of refLabelledPoint
136             is.readEnd("refLabelledPoint");
138             // Check state of Istream
139             is.check("operator>>(Istream&, refLabelledPoint");
141             return is;
142         }
145 //- Specify data associated with refLabelledPoint type is contiguous
146 template<>
147 inline bool contiguous<refLabelledPoint>() {return true;}
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 } // End namespace Foam
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 #endif
157 // ************************************************************************* //