| 1 |
#ifndef TIMEDDISKBUFFER_H |
| 2 |
#define TIMEDDISKBUFFER_H |
| 3 |
|
| 4 |
#include <cvd/diskbuffer2.h> |
| 5 |
|
| 6 |
namespace CVD |
| 7 |
{ |
| 8 |
|
| 9 |
namespace Exceptions |
| 10 |
{ |
| 11 |
|
| 12 |
|
| 13 |
namespace TimedDiskBuffer |
| 14 |
{ |
| 15 |
|
| 16 |
|
| 17 |
struct All : public CVD::Exceptions::VideoBuffer::All |
| 18 |
{ |
| 19 |
using CVD::Exceptions::VideoBuffer::All::All; |
| 20 |
}; |
| 21 |
|
| 22 |
|
| 23 |
struct IncompatibleListLengths : public All |
| 24 |
{ |
| 25 |
IncompatibleListLengths(); |
| 26 |
}; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
template <class T> |
| 38 |
class TimedDiskBuffer : public CVD::DiskBuffer2<T> |
| 39 |
{ |
| 40 |
public: |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
TimedDiskBuffer(const std::vector<std::string>& names, const std::vector<double>& times, CVD::VideoBufferFlags::OnEndOfBuffer eob = CVD::VideoBufferFlags::RepeatLastFrame); |
| 47 |
|
| 48 |
virtual CVD::DiskBuffer2Frame<T>* get_frame(); |
| 49 |
|
| 50 |
protected: |
| 51 |
std::vector<double> file_times; |
| 52 |
}; |
| 53 |
|
| 54 |
template <class T> |
| 55 |
inline TimedDiskBuffer<T>::TimedDiskBuffer(const std::vector<std::string>& names, const std::vector<double>& times, CVD::VideoBufferFlags::OnEndOfBuffer eob) |
| 56 |
: CVD::DiskBuffer2<T>(names, 1, eob) |
| 57 |
{ |
| 58 |
if(times.size() != names.size()) |
| 59 |
throw Exceptions::TimedDiskBuffer::IncompatibleListLengths(); |
| 60 |
file_times = times; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
template <class T> |
| 67 |
inline CVD::DiskBuffer2Frame<T>* TimedDiskBuffer<T>::get_frame() |
| 68 |
{ |
| 69 |
int current_frame = this->next_frame; |
| 70 |
if(current_frame < 0) |
| 71 |
current_frame = 0; |
| 72 |
|
| 73 |
CVD::DiskBuffer2Frame<T>* vf = CVD::DiskBuffer2<T>::get_frame(); |
| 74 |
vf->timestamp(file_times[current_frame]); |
| 75 |
return vf; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
#endif |