Don't do an "or" operation of the return IDs with TAGBASE_NATMEG
[AROS-Contrib.git] / FryingPan / Optical / OptItem.cpp
blob6954f5abbcdb95917932ea9d8f6c0a1b704e17ca
1 /*
2 * FryingPan - Amiga CD/DVD Recording Software (User Interface and supporting Libraries only)
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (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 Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "OptItem.h"
22 using namespace GenNS;
24 OptItem::OptItem(IOptItem *parent)
26 di_parent = parent;
27 di_itemtype = Item_Disc;
28 di_number = 0;
29 di_flags = 0;
30 di_datatype = Data_Unknown;
32 di_pregap = 0;
33 di_postgap = 0;
35 di_start = 0;
36 di_datasize = 0;
37 di_actual = 0;
38 di_sectorsize = 0;
39 di_opencnt = 0;
41 di_prot = false;
42 di_preemph = false;
43 di_incremental = false;
44 di_blank = false;
45 di_cdtext = false;
46 di_packetlength = 16;
48 di_discid = 0;
50 claim();
53 OptItem::~OptItem()
55 di_children.ForEach(&sFreeChild);
58 bool OptItem::sFreeChild(IOptItem* const& child)
60 child->dispose();
61 return true;
64 IOptItem *OptItem::addChild(IOptItem* child)
66 di_children << child;
67 return child;
70 void OptItem::printReport(DbgHandler *__dbg) const
72 if (0 == __dbg)
73 return;
75 _D(Lvl_Info, "Item type: %s", (int)(getItemType() == Item_Disc ? "Disc" :
76 getItemType() == Item_Session ? "Session" :
77 getItemType() == Item_Track ? "Track" : "Index"));
78 _D(Lvl_Info, "Item number: %ld", getItemNumber());
79 _D(Lvl_Info, "Flags: %ld", getFlags());
80 _D(Lvl_Info, "Type: %ld", getDataType());
81 _D(Lvl_Info, "Start: %ld", getStartAddress());
82 _D(Lvl_Info, "End: %ld", getEndAddress());
83 // _d(Lvl_Info, "Actual: %ld", GetActualAddress());
84 _D(Lvl_Info, "Total: %ld", getBlockCount());
85 _D(Lvl_Info, "SectorSize: %ld", getSectorSize());
86 _D(Lvl_Info, "Protected?: %ld", isProtected());
87 _D(Lvl_Info, "Preemph.?: %ld", isPreemphasized());
88 _D(Lvl_Info, "Incremental?: %ld", isIncremental());
89 _D(Lvl_Info, "Blank?: %ld", isBlank());
90 _D(Lvl_Info, "Packet size: %ld", getPacketSize());
91 _D(Lvl_Info, "-----------------------");
95 * inherited methods go here
98 void OptItem::claim() const
100 const_cast<OptItem*>(this)->di_sync.Acquire();
101 ++const_cast<OptItem*>(this)->di_opencnt;
102 const_cast<OptItem*>(this)->di_sync.Release();
105 void OptItem::dispose() const
107 const_cast<OptItem*>(this)->di_sync.Acquire();
108 ASSERT(di_opencnt != 0);
109 --const_cast<OptItem*>(this)->di_opencnt;
110 if (di_opencnt == 0)
111 delete const_cast<OptItem*>(this);
112 else
113 const_cast<OptItem*>(this)->di_sync.Release();
116 EItemType OptItem::getItemType() const
118 return di_itemtype;
121 void OptItem::setItemType(EItemType lNewType)
123 di_itemtype = lNewType;
126 uint16 OptItem::getItemNumber() const
128 return di_number;
131 void OptItem::setItemNumber(uint16 number)
133 di_number = number;
136 EDataType OptItem::getDataType() const
138 return di_datatype;
141 void OptItem::setDataType(EDataType lNewType)
143 di_datatype = lNewType;
146 uint16 OptItem::getPreGapSize() const
148 return di_pregap;
151 void OptItem::setPreGapSize(uint16 lNewSize)
153 di_pregap = lNewSize;
156 uint16 OptItem::getPostGapSize() const
158 return di_postgap;
161 void OptItem::setPostGapSize(uint16 lNewSize)
163 di_postgap = lNewSize;
166 int32 OptItem::getStartAddress() const
168 if (getFlags() & DIF_RelativeSize)
170 return getParent()->getDataStartAddress() + di_start;
172 return di_start;
175 void OptItem::setStartAddress(int32 lNewAddress)
177 di_start = lNewAddress;
180 int32 OptItem::getEndAddress() const
182 return getStartAddress() + getDataBlockCount() + getPreGapSize() + getPostGapSize() - 1;
185 void OptItem::setEndAddress(int32 lNewAddress)
187 di_datasize = lNewAddress + 1 - getPreGapSize() - getPostGapSize() - getStartAddress();
190 int32 OptItem::getBlockCount() const
192 return (getEndAddress() + 1) - getStartAddress();
195 int32 OptItem::getDataBlockCount() const
197 if (getFlags() & DIF_RelativeSize)
199 if (di_datasize == -1)
200 return getParent()->getDataBlockCount();
202 return di_datasize;
205 void OptItem::setDataBlockCount(int32 size)
207 di_datasize = size;
210 int32 OptItem::getDataStartAddress() const
212 return getStartAddress() + getPreGapSize();
215 int32 OptItem::getDataEndAddress() const
217 return getStartAddress() + getPreGapSize() + getDataBlockCount() - 1;
220 bool OptItem::isProtected() const
222 return di_prot;
225 void OptItem::setProtected(bool bProtected)
227 di_prot = bProtected;
230 bool OptItem::isPreemphasized() const
232 return di_preemph;
235 void OptItem::setPreemphasized(bool bPreemph)
237 di_preemph = bPreemph;
240 bool OptItem::isIncremental() const
242 return di_incremental;
245 void OptItem::setIncremental(bool bState)
247 di_incremental = bState;
250 bool OptItem::hasCDText() const
252 return di_cdtext;
255 void OptItem::setCDText(bool bCDText)
257 di_cdtext = bCDText;
260 const char* OptItem::getCDTTitle() const
262 return di_title.Data();
265 void OptItem::setCDTTitle(const char* sNewTitle)
267 di_title = sNewTitle;
268 if (di_title.Length() > 0)
269 setCDText(true);
272 const char* OptItem::getCDTArtist() const
274 return di_artist.Data();
277 void OptItem::setCDTArtist(const char* sNewArtist)
279 di_artist = sNewArtist;
280 if (di_artist.Length() > 0)
281 setCDText(true);
284 const char* OptItem::getCDTMessage() const
286 return di_message.Data();
289 void OptItem::setCDTMessage(const char* sNewMessage)
291 di_message = sNewMessage;
292 if (di_message.Length() > 0)
293 setCDText(true);
296 const char* OptItem::getCDTLyrics() const
298 return di_lyrics.Data();
301 void OptItem::setCDTLyrics(const char* sNewLyrics)
303 di_lyrics = sNewLyrics;
304 if (di_lyrics.Length() > 0)
305 setCDText(true);
308 const char* OptItem::getCDTComposer() const
310 return di_composer.Data();
313 void OptItem::setCDTComposer(const char* sNewComposer)
315 di_composer = sNewComposer;
316 if (di_composer.Length() > 0)
317 setCDText(true);
320 const char* OptItem::getCDTDirector() const
322 return di_director.Data();
325 void OptItem::setCDTDirector(const char* sNewDirector)
327 di_director = sNewDirector;
328 if (di_director.Length() > 0)
329 setCDText(true);
332 const IOptItem*OptItem::getParent() const
334 return di_parent;
337 const IOptItem*OptItem::getChild(int32 num) const
339 return di_children[num];
342 int32 OptItem::getChildCount() const
344 return di_children.Count();
347 bool OptItem::isBlank() const
349 return di_blank;
352 void OptItem::setBlank(bool blank)
354 di_blank = blank;
357 uint16 OptItem::getSectorSize() const
359 return di_sectorsize;
362 void OptItem::setSectorSize(uint16 size)
364 di_sectorsize = size;
367 uint32 OptItem::getDiscID() const
369 return di_discid;
372 void OptItem::setDiscID(uint32 id)
374 di_discid = id;
377 uint16 OptItem::getPacketSize() const
379 return di_packetlength;
382 void OptItem::setPacketSize(uint16 lNewSize)
384 di_packetlength = lNewSize;
387 uint16 OptItem::getFlags() const
389 return di_flags;
392 void OptItem::setFlags(uint16 lNewFlags)
394 di_flags = lNewFlags;
397 void OptItem::setComplete(bool cmpl)
399 di_complete = cmpl;
402 bool OptItem::isComplete() const
404 return di_complete;