summaryrefslogtreecommitdiffabout
path: root/lib/event.cc
authorMichael Krelin <hacker@klever.net>2006-08-11 16:01:56 (UTC)
committer Michael Krelin <hacker@klever.net>2006-08-11 16:01:56 (UTC)
commit0c21a7a0d5b84dc6726462f0fbe51b8c32433262 (patch) (side-by-side diff)
tree9df6334cb1a61efebe68f7bcef9aa119a823626a /lib/event.cc
parent9bcc235e575a95989a5903394c127accbeef2e0f (diff)
downloadmidillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.zip
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.gz
midillo-0c21a7a0d5b84dc6726462f0fbe51b8c32433262.tar.bz2
initial commit into repository0.0
Diffstat (limited to 'lib/event.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/event.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/event.cc b/lib/event.cc
new file mode 100644
index 0000000..39438fa
--- a/dev/null
+++ b/lib/event.cc
@@ -0,0 +1,58 @@
+#include <midillo/event.h>
+#include <midillo/util.h>
+
+namespace midillo {
+
+ void event_t::load(int& rs,istream& s) {
+ deltat = readVL(s);
+ message.load(rs,s);
+ }
+
+ void event_t::save(int& rs,ostream& s) const {
+ writeVL(s,deltat);
+ message.save(rs,s);
+ }
+
+ unsigned long event_t::calculate_save_size(int& rs) const {
+ return calcVLsize(deltat) + message.calculate_save_size(rs);
+ }
+
+ void event_t::dump(ostream& s) const {
+ std::ios::fmtflags ff = s.flags();
+ s.unsetf(std::ios::hex); s.setf(std::ios::dec);
+ s << "deltat=" << deltat << " [" << message << "]";
+ s.flags(ff);
+ }
+
+
+ events_t::iterator events_t::append_event() {
+ static event_t empty;
+ return insert(end(),empty);
+ }
+
+ void events_t::load(istream& s) {
+ int rs = -1;
+ for(;;) {
+ iterator i=append_event();
+ i->load(rs,s);
+ if(i->message.is_meta(meta_EOT))
+ break;
+ }
+ }
+
+ void events_t::save(ostream& s) const {
+ int rs = -1;
+ for(const_iterator i=begin();i!=end();++i) {
+ i->save(rs,s);
+ }
+ }
+
+ unsigned long events_t::calculate_save_size() const {
+ unsigned long rv = 0;
+ int rs = -1;
+ for(const_iterator i=begin();i!=end();++i) {
+ rv += i->calculate_save_size(rs);
+ }
+ return rv;
+ }
+}