cvd/timeddiskbuffer.h

00001 /*
00002     This file is part of the CVD Library.
00003 
00004     Copyright (C) 2005 The Authors
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2.1 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public
00017     License along with this library; if not, write to the Free Software
00018     Foundation, Inc.,
00019     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 */
00021 #ifndef TIMEDDISKBUFFER_H
00022 #define TIMEDDISKBUFFER_H
00023 
00024 #include <cvd/diskbuffer2.h>
00025 
00026 namespace CVD {
00027 
00028     namespace Exceptions
00029     {
00032         namespace TimedDiskBuffer
00033         {
00036             struct All: public CVD::Exceptions::VideoBuffer::All { };
00039             struct IncompatibleListLengths: public All { IncompatibleListLengths(); };
00040         }
00041     }
00042 
00050     template<class T>
00051     class TimedDiskBuffer: public CVD::DiskBuffer2<T>
00052     {
00053     public:
00059         TimedDiskBuffer(const std::vector<std::string>& names, const std::vector<double> & times , CVD::VideoBufferFlags::OnEndOfBuffer eob = CVD::VideoBufferFlags::RepeatLastFrame);
00060     
00061         virtual CVD::DiskBuffer2Frame<T>* get_frame();
00062     protected:
00063         std::vector<double> file_times;
00064     };
00065     
00066     template<class T>
00067     inline TimedDiskBuffer<T>::TimedDiskBuffer(const std::vector<std::string>& names, const std::vector<double> & times, CVD::VideoBufferFlags::OnEndOfBuffer eob )
00068     : CVD::DiskBuffer2<T>(names, 1, eob )
00069     {
00070         if(times.size() != names.size())
00071             throw Exceptions::TimedDiskBuffer::IncompatibleListLengths();
00072         file_times = times;
00073     }
00074     
00075     //
00076     // GET FRAME
00077     //
00078     template<class T>
00079     inline CVD::DiskBuffer2Frame<T>* TimedDiskBuffer<T>::get_frame()
00080     {
00081         int current_frame = this->next_frame;
00082         if(current_frame < 0)
00083             current_frame = 0;
00084         // get a frame from the super class
00085         CVD::DiskBuffer2Frame<T> * vf = CVD::DiskBuffer2<T>::get_frame();
00086         vf->timestamp(file_times[current_frame]);
00087         return vf;
00088     }
00089 }
00090 
00091 #endif

Generated on Wed Feb 18 10:23:02 2009 for CVD by  doxygen 1.5.3