iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointCloud2DataImpl.H
Go to the documentation of this file.
1 //NRT_HEADER_BEGIN
2 /*! @file PointCloud2/details/PointCloud2DataImpl.H */
3 
4 // ////////////////////////////////////////////////////////////////////////
5 // The iLab Neuromorphic Robotics Toolkit (NRT) //
6 // Copyright 2010 by the University of Southern California (USC) and the //
7 // iLab at USC. //
8 // //
9 // iLab - University of Southern California //
10 // Hedco Neurociences Building, Room HNB-10 //
11 // Los Angeles, Ca 90089-2520 - USA //
12 // //
13 // See http://ilab.usc.edu for information about this project. //
14 // ////////////////////////////////////////////////////////////////////////
15 // This file is part of The iLab Neuromorphic Robotics Toolkit. //
16 // //
17 // The iLab Neuromorphic Robotics Toolkit is free software: you can //
18 // redistribute it and/or modify it under the terms of the GNU General //
19 // Public License as published by the Free Software Foundation, either //
20 // version 3 of the License, or (at your option) any later version. //
21 // //
22 // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
23 // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
24 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
25 // PURPOSE. See the GNU General Public License for more details. //
26 // //
27 // You should have received a copy of the GNU General Public License //
28 // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
29 // <http://www.gnu.org/licenses/>. //
30 // ////////////////////////////////////////////////////////////////////////
31 //
32 // Primary maintainer for this file: Shane Grant
33 //
34 //NRT_HEADER_END
35 
36 #ifndef NRT_POINTCLOUD2_DETAILS_POINTCLOUD2DATAIMPL_H_
37 #define NRT_POINTCLOUD2_DETAILS_POINTCLOUD2DATAIMPL_H_
38 
39 //! @cond PRIVATE_NEVERDEFINED
40 template <class ... Types> inline
41 nrt::PointCloud2Data<Types...>::PointCloud2Data( Geometry const & geo ) : itsGeometry( geo )
42 { }
43 
44 template <class ... Types>
45 template <class ... InitTypes> inline
46 nrt::PointCloud2Data<Types...>::PointCloud2Data( Geometry const & geo, InitTypes const & ... initValues ) :
47  BagType( std::move( StreamableGenericBag<InitTypes...>( initValues... ) ) ),
48  itsGeometry( geo )
49 { }
50 
51 template <class ... Types>
52 template <class ... InitTypes> inline
53 nrt::PointCloud2Data<Types...>::PointCloud2Data( PointCloud2Data<InitTypes...> const & other ) :
54  BagType( std::move( StreamableGenericBag<InitTypes...>( other ) ) ),
55  itsGeometry( other.geometry() )
56 { }
57 
58 template <class ... Types>
59 template <bool IsConst, class ... InitTypes> inline
60 nrt::PointCloud2Data<Types...>::PointCloud2Data( PointCloud2DataRefBase<IsConst, InitTypes...> const & other ) :
61  BagType( std::move( StreamableGenericBag<InitTypes...>( other ) ) ),
62  itsGeometry( other.itsGeometry() )
63 { }
64 
65 template <class ... Types>
66 template <class ... InitTypes> inline
67 nrt::PointCloud2Data<Types...>::PointCloud2Data( PointCloud2Data<InitTypes...> && other ) :
68  BagType( std::move( StreamableGenericBag<InitTypes...>( std::forward<PointCloud2Data<InitTypes...>>( other ) ) ) ),
69  itsGeometry( std::move( other.itsGeometry() ) )
70 { }
71 
72 template <class ... Types>
73 template <bool IsConst, class ... InitTypes> inline
74 nrt::PointCloud2Data<Types...>::PointCloud2Data( PointCloud2DataRefBase<IsConst, InitTypes...> && other ) :
75  BagType( std::move( StreamableGenericBag<InitTypes...>( std::forward<PointCloud2DataRefBase<IsConst, InitTypes...>>( other ) ) ) ),
76  itsGeometry( std::move( other.geometry() ) )
77 { }
78 
79 template <class ... Types>
80 template <class ... InitTypes> inline
81 auto nrt::PointCloud2Data<Types...>::operator=( PointCloud2Data<InitTypes...> const & other ) -> PointCloud2Data &
82 {
83  itsGeometry = other.geometry();
84  BagType::operator=( other );
85 
86  return *this;
87 }
88 
89 template <class ... Types>
90 template <bool IsConst, class ... InitTypes> inline
91 auto nrt::PointCloud2Data<Types...>::operator=( PointCloud2DataRefBase<IsConst, InitTypes...> const & other ) -> PointCloud2Data &
92 {
93  itsGeometry = other.geometry();
94  BagType::operator=( other );
95 
96  return *this;
97 }
98 
99 template <class ... Types>
100 template <class ... InitTypes> inline
101 auto nrt::PointCloud2Data<Types...>::operator=( PointCloud2Data<InitTypes...> && other ) -> PointCloud2Data &
102 {
103  itsGeometry = std::move( other.geometry() );
104  BagType::operator=( std::forward<PointCloud2Data<InitTypes...>>( other ) );
105 
106  return *this;
107 }
108 
109 template <class ... Types>
110 template <bool IsConst, class ... InitTypes> inline
111 auto nrt::PointCloud2Data<Types...>::operator=( PointCloud2DataRefBase<IsConst, InitTypes...> && other ) -> PointCloud2Data &
112 {
113  itsGeometry = std::move( other.geometry() );
114  BagType::operator=( std::forward<PointCloud2DataRefBase<IsConst, InitTypes...>>( other ) );
115 
116  return *this;
117 }
118 
119 template <class ... Types> inline
120 auto nrt::PointCloud2Data<Types...>::geometry() -> Geometry &
121 {
122  return itsGeometry;
123 }
124 
125 template <class ... Types> inline
126 auto nrt::PointCloud2Data<Types...>::geometry() const -> Geometry const &
127 {
128  return itsGeometry;
129 }
130 
131 ///////////////////////////////////////////////////////////////////////////////
132 ///// CONST VERSION OF POINTCLOUD2DATAREFBASE
133 ///////////////////////////////////////////////////////////////////////////////
134 
135 template <class ... Types> inline
136 nrt::PointCloud2DataRefBase<true, Types...>::PointCloud2DataRefBase( Geometry const & geo, Types const & ... initValues ) :
137  BagType( initValues... ),
138  itsGeometry( geo )
139 { }
140 
141 template <class ... Types> inline
142 nrt::PointCloud2DataRefBase<true, Types...>::PointCloud2DataRefBase( Geometry const & geo, GenericBag<Types const &...> const & initValues ) :
143  BagType( initValues ),
144  itsGeometry( geo )
145 { }
146 
147 template <class ... Types>
148 template <class ... OtherTypes> inline
149 nrt::PointCloud2DataRefBase<true, Types...>::PointCloud2DataRefBase( PointCloud2Data<OtherTypes...> const & other ) :
150  BagType( other ),
151  itsGeometry( other.geometry() )
152 { }
153 
154 template <class ... Types>
155 template <bool OtherConst, class ... OtherTypes> inline
156 nrt::PointCloud2DataRefBase<true, Types...>::PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> const & other ) :
157  BagType( other ),
158  itsGeometry( other.geometry() )
159 { }
160 
161 template <class ... Types>
162 template <bool OtherConst, class ... OtherTypes> inline
163 nrt::PointCloud2DataRefBase<true, Types...>::PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> && other ) :
164  BagType( std::move( other ) ),
165  itsGeometry( other.geometry() ) // geometry not actually moved, we just create a reference to what the original referenced
166 { }
167 
168 template <class ... Types>
169 template <class ... OtherTypes> inline
170 auto nrt::PointCloud2DataRefBase<true, Types...>::operator=( PointCloud2Data<OtherTypes...> const & other ) -> PointCloud2DataRefBase &
171 {
172  itsGeometry = other.geometry();
173  BagType::operator=( other );
174 
175  return *this;
176 }
177 
178 template <class ... Types>
179 template <class ... OtherTypes> inline
180 auto nrt::PointCloud2DataRefBase<true, Types...>::operator=( PointCloud2Data<OtherTypes...> && other ) -> PointCloud2DataRefBase &
181 {
182  itsGeometry = other.geometry();
183  BagType::operator=( std::move( other ) );
184 
185  return *this;
186 }
187 
188 template <class ... Types>
189 template <bool OtherConst, class ... OtherTypes> inline
190 auto nrt::PointCloud2DataRefBase<true, Types...>::operator=( PointCloud2DataRefBase<OtherConst, OtherTypes...> const & other ) -> PointCloud2DataRefBase &
191 {
192  itsGeometry = other.geometry();
193  BagType::operator=( other );
194 
195  return *this;
196 }
197 
198 template <class ... Types>
199 template <bool OtherConst, class ... OtherTypes> inline
200 auto nrt::PointCloud2DataRefBase<true, Types...>::operator=( PointCloud2DataRefBase<OtherConst, OtherTypes...> && other ) -> PointCloud2DataRefBase &
201 {
202  itsGeometry = other.geometry();
203  BagType::operator=( std::move( other ) );
204 
205  return *this;
206 }
207 
208 template <class ... Types> inline
209 auto nrt::PointCloud2DataRefBase<true, Types...>::geometry() const -> Geometry const &
210 {
211  return itsGeometry.get();
212 }
213 
214 ///////////////////////////////////////////////////////////////////////////////
215 ///// NORMAL VERSION OF POINTCLOUD2DATAREFBASE
216 ///////////////////////////////////////////////////////////////////////////////
217 
218 template <class ... Types> inline
219 nrt::PointCloud2DataRefBase<false, Types...>::PointCloud2DataRefBase( Geometry & geo, Types & ... initValues ) :
220  BagType( initValues... ),
221  itsGeometry( geo )
222 { }
223 
224 template <class ... Types> inline
225 nrt::PointCloud2DataRefBase<false, Types...>::PointCloud2DataRefBase( Geometry & geo, GenericBag<Types &...> const & initValues ) :
226  BagType( initValues ),
227  itsGeometry( geo )
228 { }
229 
230 template <class ... Types>
231 template <class ... OtherTypes> inline
232 nrt::PointCloud2DataRefBase<false, Types...>::PointCloud2DataRefBase( PointCloud2Data<OtherTypes...> const & other ) :
233  BagType( other ),
234  itsGeometry( const_cast<Geometry &>( other.geometry() ) ) // strip off artificial const introduced by copy constructor
235 { }
236 
237 template <class ... Types>
238 template <bool OtherConst, class ... OtherTypes> inline
239 nrt::PointCloud2DataRefBase<false, Types...>::PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> const & other ) :
240  BagType( other ),
241  itsGeometry( other.geometry() )
242 {
243  static_assert( !OtherConst, "Cannot create a PointCloud2DataRef to constant references contained in a PointCloud2ConstDataRef" );
244 }
245 
246 template <class ... Types>
247 template <bool OtherConst, class ... OtherTypes> inline
248 nrt::PointCloud2DataRefBase<false, Types...>::PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> && other ) :
249  BagType( std::move( other ) ),
250  itsGeometry( other.geometry() ) // geometry not actually moved, we just create a reference to what the original referenced
251 {
252  static_assert( !OtherConst, "Cannot create a PointCloud2DataRef to constant references contained in a PointCloud2ConstDataRef" );
253 }
254 
255 template <class ... Types>
256 template <class ... OtherTypes> inline
257 auto nrt::PointCloud2DataRefBase<false, Types...>::operator=( PointCloud2Data<OtherTypes...> const & other ) -> PointCloud2DataRefBase &
258 {
259  itsGeometry.get() = other.geometry();
260  BagType::operator=( other );
261 
262  return *this;
263 }
264 
265 template <class ... Types>
266 template <class ... OtherTypes> inline
267 auto nrt::PointCloud2DataRefBase<false, Types...>::operator=( PointCloud2Data<OtherTypes...> && other ) -> PointCloud2DataRefBase &
268 {
269  itsGeometry.get() = other.geometry();
270  BagType::operator=( std::move( other ) );
271 
272  return *this;
273 }
274 
275 template <class ... Types>
276 template <bool OtherConst, class ... OtherTypes> inline
277 auto nrt::PointCloud2DataRefBase<false, Types...>::operator=( PointCloud2DataRefBase<OtherConst, OtherTypes...> const & other ) -> PointCloud2DataRefBase &
278 {
279  itsGeometry.get() = other.geometry();
280  BagType::operator=( other );
281 
282  return *this;
283 }
284 
285 template <class ... Types>
286 template <bool OtherConst, class ... OtherTypes> inline
287 auto nrt::PointCloud2DataRefBase<false, Types...>::operator=( PointCloud2DataRefBase<OtherConst, OtherTypes...> && other ) -> PointCloud2DataRefBase &
288 {
289  itsGeometry.get() = other.geometry();
290  BagType::operator=( std::move( other ) );
291 
292  return *this;
293 }
294 
295 template <class ... Types> inline
297 {
298  return itsGeometry.get();
299 }
300 
301 template <class ... Types> inline
302 auto nrt::PointCloud2DataRefBase<false, Types...>::geometry() const -> Geometry const &
303 {
304  return itsGeometry.get();
305 }
306 
307 ///////////////////////////////////////////////////////////////////////////////
308 ///////////////////////////////////////////////////////////////////////////////
309 ///////////////////////////////////////////////////////////////////////////////
310 template <class ... Fields> inline
311 std::ostream & nrt::operator<<( std::ostream & out, PointCloud2Data<Fields...> const & data )
312 {
313  out << data.geometry();
314  if( sizeof...(Fields) )
315  out << " -> " << static_cast<StreamableGenericBag<Fields...>>( data );
316 
317  return out;
318 }
319 
320 template <class ... Fields> inline
321 std::istream & nrt::operator>>( std::istream & in, PointCloud2Data<Fields...> & data )
322 {
323  in >> data.geometry();
324  in >> static_cast<StreamableGenericBag<Fields...>>( data );
325 
326  return in;
327 }
328 
329 template <bool IsConst, class ... Fields> inline
330 std::ostream & nrt::operator<<( std::ostream & out, PointCloud2DataRefBase<IsConst, Fields...> const & data )
331 {
332  out << data.geometry();
333  if( sizeof...(Fields) )
334  out << " -> " << static_cast<StreamableGenericBag<Fields...>>( data );
335 
336  return out;
337 }
338 //! @endcond
339 
340 #endif // NRT_POINTCLOUD2_DETAILS_POINTCLOUD2DATAIMPL_H_