Merge branch 'master' into cairocanvas
[ardour.git] / libs / evoral / evoral / EventList.hpp
1 /* This file is part of Evoral.
2  * Copyright (C) 2009 Paul Davis
3  *
4  * Evoral is free software; you can redistribute it and/or modify it under the
5  * terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16  */
17
18 #ifndef EVORAL_EVENT_LIST_HPP
19 #define EVORAL_EVENT_LIST_HPP
20
21 #include <list>
22
23 #include "evoral/visibility.h"
24 #include "evoral/EventSink.hpp"
25 #include "evoral/types.hpp"
26 #include "evoral/Event.hpp"
27
28 namespace Evoral {
29
30
31 /** A list of events (generic time-stamped binary "blobs").
32  *
33  * Used when we need an unsorted list of Events that is also an EventSink. Absolutely nothing more.
34  */
35 template<typename Time>
36 class /*LIBEVORAL_API*/ EventList : public std::list<Evoral::Event<Time> *>, public Evoral::EventSink<Time> {
37 public:
38         EventList() {}
39
40         uint32_t write(Time  time, EventType  type, uint32_t  size, const uint8_t* buf) {
41                 this->push_back(new Evoral::Event<Time>(
42                                   type, time, size, const_cast<uint8_t*>(buf), true)); // Event copies buffer
43                 return size;
44         }
45 };
46
47
48 } // namespace Evoral
49
50 #endif // EVORAL_EVENT_LIST_HPP