the big Route structure refactor. !!!! THIS WILL ***NOT LOAD*** PRIOR 3.0 or 2.X...
[ardour.git] / libs / ardour / ardour / lv2_event_buffer.h
1 /*
2     Copyright (C) 2009 Paul Davis 
3     Author: Dave Robillard
4
5     This program is free software; you can redistribute it and/or modify it
6     under the terms of the GNU General Public License as published by the Free
7     Software Foundation; either version 2 of the License, or (at your option)
8     any later version.
9     
10     This program is distributed in the hope that it will be useful, but WITHOUT
11     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13     for more details.
14     
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __ardour_lv2_event_buffer_h__
21 #define __ardour_lv2_event_buffer_h__
22
23 #include "lv2ext/lv2_event.h"
24 #include "lv2ext/lv2_event_helpers.h"
25
26 namespace ARDOUR {
27
28
29 class LV2EventBuffer {
30 public:
31         LV2EventBuffer(size_t capacity);
32         ~LV2EventBuffer();
33
34         inline LV2_Event_Buffer*       data()       { return _data; }
35         inline const LV2_Event_Buffer* data() const { return _data; }
36         
37         inline void rewind() const { lv2_event_begin(&_iter, _data); }
38         
39         inline void reset() {
40                 _latest_frames = 0;
41                 _latest_subframes = 0;
42                 _data->event_count = 0;
43                 _data->size = 0;
44                 rewind();
45         }
46         
47         inline size_t   event_count()      const { return _data->event_count; }
48         inline uint32_t capacity()         const { return _data->capacity; }
49         inline uint32_t size()             const { return _data->size; }
50         inline uint32_t latest_frames()    const { return _latest_frames; }
51         inline uint32_t latest_subframes() const { return _latest_subframes; }
52
53         bool increment() const;
54
55         bool is_valid() const;
56
57         bool get_event(uint32_t* frames,
58                        uint32_t* subframes,
59                        uint16_t* type,
60                        uint16_t* size,
61                        uint8_t** data) const;
62
63         bool append(uint32_t       frames,
64                     uint32_t       subframes,
65                     uint16_t       type,
66                     uint16_t       size,
67                     const uint8_t* data);
68
69         bool append(const LV2_Event_Buffer* buf);
70
71 private:
72         LV2_Event_Buffer*          _data;             ///< Contents
73         mutable LV2_Event_Iterator _iter;             ///< Iterator into _data
74         uint32_t                   _latest_frames;    ///< Latest time of all events (frames)
75         uint32_t                   _latest_subframes; ///< Latest time of all events (subframes)
76 };
77
78
79 } // namespace ARDOUR
80
81 #endif // __ardour_lv2_event_buffer_h__