Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/io/include/pcl/io/file_grabber.h
00001 
00002 /*
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Point Cloud Library (PCL) - www.pointclouds.org
00006  *  Copyright (c) 2010-2011, Willow Garage, Inc.
00007  *  Copyright (c) 2012-, Open Perception, Inc.
00008  *
00009  *  All rights reserved.
00010  *
00011  *  Redistribution and use in source and binary forms, with or without
00012  *  modification, are permitted provided that the following conditions
00013  *  are met:
00014  *
00015  *   * Redistributions of source code must retain the above copyright
00016  *     notice, this list of conditions and the following disclaimer.
00017  *   * Redistributions in binary form must reproduce the above
00018  *     copyright notice, this list of conditions and the following
00019  *     disclaimer in the documentation and/or other materials provided
00020  *     with the distribution.
00021  *   * Neither the name of the copyright holder(s) nor the names of its
00022  *     contributors may be used to endorse or promote products derived
00023  *     from this software without specific prior written permission.
00024  *
00025  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00028  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00029  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00030  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00031  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00032  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00033  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00034  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00035  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  *  POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * $Id: file_grabber.h 8413 2013-01-15 08:37:39Z sdmiller $
00039  *
00040  */
00041 
00042 #pragma once
00043 #ifndef PCL_IO_FILE_GRABBER_H_
00044 #define PCL_IO_FILE_GRABBER_H_
00045 
00046 #include <pcl/point_cloud.h>
00047 
00048 namespace pcl
00049 {
00050   /** \brief FileGrabber provides a container-style interface for grabbers which operate on fixed-size input
00051     * \author Stephen Miller
00052     * \ingroup io
00053     */
00054   template <typename PointT>
00055   class PCL_EXPORTS FileGrabber
00056   {
00057   public:
00058 
00059     /** \brief Empty destructor */
00060     virtual ~FileGrabber () {}
00061 
00062     /** \brief operator[] Returns the idx-th cloud in the dataset, without bounds checking.
00063      *  Note that in the future, this could easily be modified to do caching
00064      *  \param[in] idx The frame to load
00065      */
00066     virtual const boost::shared_ptr< const pcl::PointCloud<PointT> >
00067     operator[] (size_t idx) const = 0;
00068 
00069     /** \brief size Returns the number of clouds currently loaded by the grabber */
00070     virtual size_t
00071     size () const = 0;
00072     
00073     /** \brief at Returns the idx-th cloud in the dataset, with bounds checking
00074      *  \param[in] idx The frame to load
00075      */
00076     virtual const boost::shared_ptr< const pcl::PointCloud<PointT> >
00077     at (size_t idx) const
00078     {
00079       if (idx >= size ())
00080       {
00081         // Throw error 
00082         throw pcl::IOException ("[pcl::FileGrabber] Attempted to access element which is out of bounds!");
00083       }
00084       else
00085       {
00086         return (operator[] (idx));
00087       }
00088     }
00089   };
00090 }
00091 #endif//PCL_IO_FILE_GRABBER_H_
00092