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
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.
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.
22 using namespace GenNS
;
24 OptItem::OptItem(IOptItem
*parent
)
27 di_itemtype
= Item_Disc
;
30 di_datatype
= Data_Unknown
;
43 di_incremental
= false;
55 di_children
.ForEach(&sFreeChild
);
58 bool OptItem::sFreeChild(IOptItem
* const& child
)
64 IOptItem
*OptItem::addChild(IOptItem
* child
)
70 void OptItem::printReport(DbgHandler
*__dbg
) const
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
;
111 delete const_cast<OptItem
*>(this);
113 const_cast<OptItem
*>(this)->di_sync
.Release();
116 EItemType
OptItem::getItemType() const
121 void OptItem::setItemType(EItemType lNewType
)
123 di_itemtype
= lNewType
;
126 uint16
OptItem::getItemNumber() const
131 void OptItem::setItemNumber(uint16 number
)
136 EDataType
OptItem::getDataType() const
141 void OptItem::setDataType(EDataType lNewType
)
143 di_datatype
= lNewType
;
146 uint16
OptItem::getPreGapSize() const
151 void OptItem::setPreGapSize(uint16 lNewSize
)
153 di_pregap
= lNewSize
;
156 uint16
OptItem::getPostGapSize() const
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
;
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();
205 void OptItem::setDataBlockCount(int32 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
225 void OptItem::setProtected(bool bProtected
)
227 di_prot
= bProtected
;
230 bool OptItem::isPreemphasized() const
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
255 void OptItem::setCDText(bool 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)
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)
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)
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)
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)
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)
332 const IOptItem
*OptItem::getParent() const
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
352 void OptItem::setBlank(bool 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
372 void OptItem::setDiscID(uint32 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
392 void OptItem::setFlags(uint16 lNewFlags
)
394 di_flags
= lNewFlags
;
397 void OptItem::setComplete(bool cmpl
)
402 bool OptItem::isComplete() const