~ubuntu-branches/ubuntu/utopic/cdrdao/utopic

« back to all changes in this revision

Viewing changes to trackdb/TrackDataList.cc

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Suffield
  • Date: 2004-06-24 22:33:16 UTC
  • Revision ID: james.westby@ubuntu.com-20040624223316-534onzugaeeyq61j
Tags: upstream-1.1.9
ImportĀ upstreamĀ versionĀ 1.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  cdrdao - write audio CD-Rs in disc-at-once mode
 
2
 *
 
3
 *  Copyright (C) 1998-2001 Andreas Mueller <andreas@daneb.de>
 
4
 *
 
5
 *  This program is free software; you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation; either version 2 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 */
 
19
 
 
20
 
 
21
#include <config.h>
 
22
 
 
23
 
 
24
#include "TrackDataList.h"
 
25
#include "TrackData.h"
 
26
 
 
27
TrackDataList::TrackDataList()
 
28
{
 
29
  list_ = last_ = NULL;
 
30
  iterator_ = NULL;
 
31
  count_ = 0;
 
32
}
 
33
 
 
34
 
 
35
void TrackDataList::append(TrackData *a)
 
36
{
 
37
  Entry *ent = new Entry;
 
38
 
 
39
  ent->data = a;
 
40
  ent->next = NULL;
 
41
 
 
42
  if (list_ == NULL) 
 
43
    list_ = ent;
 
44
  else
 
45
    last_->next = ent;
 
46
 
 
47
  last_ = ent;
 
48
 
 
49
  count_++;
 
50
}
 
51
 
 
52
unsigned long TrackDataList::length() const
 
53
{
 
54
  unsigned long len = 0;
 
55
  Entry *run;
 
56
 
 
57
  for (run = list_; run != NULL; run = run->next) 
 
58
    len += run->data->length();
 
59
 
 
60
  return len;
 
61
}
 
62
 
 
63
void TrackDataList::clear()
 
64
{
 
65
  Entry *next;
 
66
 
 
67
  while (list_ != NULL) {
 
68
    next = list_->next;
 
69
 
 
70
    delete list_->data;
 
71
    delete list_;
 
72
 
 
73
    list_ = next;
 
74
  }
 
75
 
 
76
  last_ = NULL;
 
77
  iterator_ = NULL;
 
78
  count_ = 0;
 
79
}
 
80
 
 
81
const TrackData *TrackDataList::first() const
 
82
{
 
83
  if ((((TrackDataList *)this)->iterator_ = list_) != NULL)
 
84
    return iterator_->data;
 
85
  else
 
86
    return NULL;
 
87
}
 
88
 
 
89
const TrackData *TrackDataList::next() const
 
90
{
 
91
  if (iterator_ == NULL ||
 
92
      (((TrackDataList *)this)->iterator_ = iterator_->next) == NULL)
 
93
    return NULL;
 
94
  else
 
95
    return iterator_->data;
 
96
}