Point Cloud Library (PCL)  1.14.1-dev
file_grabber.h
1 
2 /*
3  * Software License Agreement (BSD License)
4  *
5  * Point Cloud Library (PCL) - www.pointclouds.org
6  * Copyright (c) 2010-2011, Willow Garage, Inc.
7  * Copyright (c) 2012-, Open Perception, Inc.
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of the copyright holder(s) nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  *
38  * $Id: file_grabber.h 8413 2013-01-15 08:37:39Z sdmiller $
39  *
40  */
41 
42 #pragma once
43 
44 #include <pcl/point_cloud.h>
45 
46 namespace pcl
47 {
48  /** \brief FileGrabber provides a container-style interface for grabbers which operate on fixed-size input
49  * \author Stephen Miller
50  * \ingroup io
51  */
52  template <typename PointT>
54  {
55  public:
56 
57  /** \brief Empty destructor */
58  virtual ~FileGrabber () = default;
59 
60  /** \brief operator[] Returns the idx-th cloud in the dataset, without bounds checking.
61  * Note that in the future, this could easily be modified to do caching
62  * \param[in] idx The frame to load
63  */
64  virtual const typename pcl::PointCloud<PointT>::ConstPtr
65  operator[] (std::size_t idx) const = 0;
66 
67  /** \brief size Returns the number of clouds currently loaded by the grabber */
68  virtual std::size_t
69  size () const = 0;
70 
71  /** \brief at Returns the idx-th cloud in the dataset, with bounds checking
72  * \param[in] idx The frame to load
73  */
74  virtual const typename pcl::PointCloud<PointT>::ConstPtr
75  at (std::size_t idx) const
76  {
77  if (idx >= size ())
78  {
79  // Throw error
80  throw pcl::IOException ("[pcl::FileGrabber] Attempted to access element which is out of bounds!");
81  }
82  return (operator[] (idx));
83  }
84  };
85 }
FileGrabber provides a container-style interface for grabbers which operate on fixed-size input.
Definition: file_grabber.h:54
virtual const pcl::PointCloud< PointT >::ConstPtr at(std::size_t idx) const
at Returns the idx-th cloud in the dataset, with bounds checking
Definition: file_grabber.h:75
virtual std::size_t size() const =0
size Returns the number of clouds currently loaded by the grabber
virtual ~FileGrabber()=default
Empty destructor.
An exception that is thrown during an IO error (typical read/write errors)
Definition: exceptions.h:182
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:414
#define PCL_EXPORTS
Definition: pcl_macros.h:325