iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointCloud2DataHelpers.H
Go to the documentation of this file.
1 //NRT_HEADER_BEGIN
2 /*! @file PointCloud2/details/PointCloud2DataHelpers.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 <wgrant@usc.edu>
33 //
34 //NRT_HEADER_END
35 
36 #ifndef NRT_POINTCLOUD2_DETAILS_POINTCLOUD2DATAHELPERS_H_
37 #define NRT_POINTCLOUD2_DETAILS_POINTCLOUD2DATAHELPERS_H_
38 
39 namespace nrt
40 {
41 #ifdef NRT_CLOUD_DOUBLE
42  typedef double POINTCLOUD2_BASE_TYPE;
43 #else
44  typedef float POINTCLOUD2_BASE_TYPE;
45 #endif // NRT_CLOUD_DOUBLE
46 
47  // Base class for all point cloud data
48  class PointCloud2DataCore{};
49 
50  //! A container for holding references to the data associated with a point cloud point
51  /*! Point cloud points can contain arbitrary data types in addition to
52  their geometric coordinate representation.
53 
54  Accessing geometry is available through the geometry() functionality whereas
55  all other data that may be held is handled through the get() functionality
56  inherited from StreamableGenericBag.
57 
58  Note that any and all data held by a reference point will exist elsewhere, usually
59  inside of an actual point cloud. This data type will most often be encountered
60  when querying a cloud for data.
61 
62  See @ref PointCloud2DataRefBaseConst for details on the constant specialization, and
63  @ref PointCloud2DataRefBaseNotConst for details on the non constant specialization.
64 
65  @note It is suggested that you use the template aliases PointCloud2DataRef and
66  PointCloud2ConstDataRef instead of the specializations of this class.
67 
68  @relates PointCloud2DataRef
69  @relates PointCloud2ConstDataRef
70 
71  @tparam Types The various types that can be represented by this data. Geometry is
72  always included regardless of types specified. Types follow the rules
73  for GenericBag (i.e.: they must be distinct using std::is_same) */
74  template <bool IsConst, class ... Types>
76 
77  // forward decl
78  template <class ... Types>
80 
81  //! A container for holding references to the data associated with a point cloud point
82  /*! This is a specialization of PointCloud2DataRefBase to deal with normal data. It is suggested
83  to interact directly with the template alias @ref PointCloud2DataRef instead of this class.
84 
85  @anchor PointCloud2DataRefBaseConst */
86  template <class ... Types>
87  class PointCloud2DataRefBase<true, Types...> : public PointCloud2DataCore, public StreamableGenericBag<Types const &...>
88  {
89  private:
91  typedef StreamableGenericBag<Types const &...> BagType;
92  typedef std::reference_wrapper<Geometry const> GeometryWrapper;
93 
94  public:
95  PointCloud2DataRefBase( Geometry const & geo, Types const & ... initialValues );
96 
97  PointCloud2DataRefBase( Geometry const & geo, GenericBag<Types const &...> const & initValues );
98 
99  template <class ... OtherTypes>
101 
102  template <bool OtherConst, class ... OtherTypes>
103  PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> const & other );
104 
105  template <class ... OtherTypes>
106  PointCloud2DataRefBase( PointCloud2Data<OtherTypes...> && other ) = delete;
107 
108  template <bool OtherConst, class ... OtherTypes>
109  PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> && other );
110 
111  template <class ... OtherTypes>
112  PointCloud2DataRefBase & operator=( PointCloud2Data<OtherTypes...> const & other );
113 
114  template <bool OtherConst, class ... OtherTypes>
115  PointCloud2DataRefBase & operator=( PointCloud2DataRefBase<OtherConst, OtherTypes...> const & other );
116 
117  template <class ... OtherTypes>
118  PointCloud2DataRefBase & operator=( PointCloud2Data<OtherTypes...> && other );
119 
120  template <bool OtherConst, class ... OtherTypes>
121  PointCloud2DataRefBase & operator=( PointCloud2DataRefBase<OtherConst, OtherTypes...> && other );
122 
123  using BagType::operator=;
124 
125  //! Get a const reference to the geometry
126  Geometry const & geometry() const;
127 
128  private:
129  GeometryWrapper itsGeometry;
130  };
131 
132  //! A container for holding constant references to the data associated with a point cloud point
133  /*! This is a specialization of PointCloud2DataRefBase to deal with const data. It is suggested
134  to interact directly with the template alias @ref PointCloud2ConstDataRef instead of this class.
135 
136  @anchor PointCloud2DataRefBaseNotConst */
137  template <class ... Types>
138  class PointCloud2DataRefBase<false, Types...> : public PointCloud2DataCore, public StreamableGenericBag<Types &...>
139  {
140  private:
142  typedef StreamableGenericBag<Types &...> BagType;
143  typedef std::reference_wrapper<Geometry> GeometryWrapper;
144 
145  public:
146  PointCloud2DataRefBase( Geometry & geo, Types & ... initialValues );
147 
148  PointCloud2DataRefBase( Geometry & geo, GenericBag<Types &...> const & initValues );
149 
150  template <class ... OtherTypes>
152 
153  template <bool OtherConst, class ... OtherTypes>
154  PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> const & other );
155 
156  template <class ... OtherTypes>
157  PointCloud2DataRefBase( PointCloud2Data<OtherTypes...> && other ) = delete;
158 
159  template <bool OtherConst, class ... OtherTypes>
160  PointCloud2DataRefBase( PointCloud2DataRefBase<OtherConst, OtherTypes...> && other );
161 
162  template <class ... OtherTypes>
163  PointCloud2DataRefBase & operator=( PointCloud2Data<OtherTypes...> const & other );
164 
165  template <bool OtherConst, class ... OtherTypes>
166  PointCloud2DataRefBase & operator=( PointCloud2DataRefBase<OtherConst,OtherTypes...> const & other );
167 
168  template <class ... OtherTypes>
169  PointCloud2DataRefBase & operator=( PointCloud2Data<OtherTypes...> && other );
170 
171  template <bool OtherConst, class ... OtherTypes>
172  PointCloud2DataRefBase & operator=( PointCloud2DataRefBase<OtherConst,OtherTypes...> && other );
173 
174  using BagType::operator=;
175 
176  //! Get a reference to the geometry
177  Geometry & geometry();
178 
179  //! Get a const reference to the geometry
180  Geometry const & geometry() const;
181 
182  private:
183  GeometryWrapper itsGeometry;
184  };
185 }
186 
187 #endif // NRT_POINTCLOUD2_DETAILS_POINTCLOUD2DATAHELPERS_H_