1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#ifndef FRAME_HPP
#define FRAME_HPP
#include "Utils.hpp"
// one frame of CD data, 2352 bytes
class Frame
{
public:
// note that the data is uninitialized w/default constructor
Frame()
{
data = new unsigned char[bytesPerFrame];
}
Frame(const unsigned char* d)
{
data = new unsigned char[bytesPerFrame];
memcpy(data, d, bytesPerFrame);
}
Frame(const Frame& r)
{
data = new unsigned char[bytesPerFrame];
memcpy(data, r.data, bytesPerFrame);
}
~Frame() { delete [] data; }
Frame& operator=(const Frame& r)
{
memcpy(data, r.data, bytesPerFrame);
return *this;
}
Frame& operator=(const unsigned char* buf)
{
memcpy(data, buf, bytesPerFrame);
return *this;
}
Frame& operator=(const char* buf)
{
memcpy(data, buf, bytesPerFrame);
return *this;
}
int operator==(const Frame& r)
{
return memcmp(data, r.data, bytesPerFrame);
}
unsigned char* operator*() const
{
return data;
}
private:
unsigned char* data;
};
#endif
|