19 #ifndef EVORAL_EVENT_HPP
20 #define EVORAL_EVENT_HPP
34 #define EVORAL_EVENT_ALLOC 1
46 template<
typename Time>
49 #ifdef EVORAL_EVENT_ALLOC
50 Event (
EventType type=0, Time time=Time(), uint32_t size=0, uint8_t* buf=NULL,
bool alloc=
false);
52 Event (
EventType type, Time time, uint32_t size,
const uint8_t* buf);
60 Event(
const Event& copy,
bool alloc);
64 const Event& operator=(
const Event& copy);
66 void set(
const uint8_t* buf, uint32_t size, Time t);
69 if (_type != other.
_type)
78 if (_size != other.
_size)
81 if (_buf == other.
_buf)
84 for (uint32_t i=0; i < _size; ++i)
85 if (_buf[i] != other.
_buf[i])
95 inline void set_buffer(uint32_t size, uint8_t* buf,
bool own) {
108 _buf = (uint8_t*) ::realloc(_buf, size);
110 _buf = (uint8_t*) ::malloc(size);
119 _original_time = Time();
120 _nominal_time = Time();
127 inline void set_buffer(uint8_t* buf) { _buf = buf; }
129 #endif // EVORAL_EVENT_ALLOC
132 inline Time
time()
const {
return _nominal_time; }
134 inline uint32_t
size()
const {
return _size; }
135 inline const uint8_t*
buffer()
const {
return _buf; }
136 inline uint8_t*
buffer() {
return _buf; }
141 void set_original_time(Time);
153 #ifdef EVORAL_EVENT_ALLOC
158 template<
typename Time>
159 std::ostream& operator<<(std::ostream& o, const Evoral::Event<Time>& ev) {
160 o <<
"Event #" << ev.id() <<
" type = " << ev.event_type() <<
" @ " << ev.time();
162 for (uint32_t n = 0; n < ev.size(); ++n) {
163 o <<
' ' << (int) ev.buffer()[n];
171 #endif // EVORAL_EVENT_HPP
EventType event_type() const
LIBEVORAL_API event_id_t event_id_counter()
void set_id(event_id_t n)
LIBEVORAL_API void init_event_id_counter(event_id_t n)
bool operator==(const Event &other) const
void realloc(uint32_t size)
void set_event_type(EventType t)
bool operator!=(const Event &other) const
LIBEVORAL_API event_id_t next_event_id()
void set_buffer(uint32_t size, uint8_t *buf, bool own)
bool operator==(Range< T > a, Range< T > b)
Time original_time() const
const uint8_t * buffer() const