1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_WaveArchiveFileReader.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_SND_WAVE_ARCHIVE_FILE_READER_H_
19 #define NW_SND_WAVE_ARCHIVE_FILE_READER_H_
20 
21 #include <nw/snd/snd_WaveArchiveFile.h>
22 
23 namespace nw {
24 namespace snd {
25 namespace internal {
26 
27 class WaveArchiveFileReader
28 {
29 public:
30     static const u32 SIGNATURE_FILE = NW_UT_MAKE_SIGWORD( 'C', 'W', 'A', 'R' );
31     static const u32 SIGNATURE_WARC_TABLE;
32 
33     WaveArchiveFileReader( const void* pWaveArchiveFile, bool isIndividual = false );
34 
35     // 初期化
36     void InitializeFileTable();
IsAvailable()37     bool IsAvailable() const { return m_pHeader != NULL; }
38 
39     u32 GetWaveFileCount() const;
40     u32 GetWaveFileSize( u32 waveIndex ) const;
41     u32 GetWaveFileOffsetFromFileHead( u32 waveIndex ) const;
42 
43     // 一括ロードの場合
44     const void* GetWaveFile( u32 waveIndex ) const;
45 
46     // 個別ロード時に利用
47     const void* SetWaveFile( u32 waveIndex, const void* pWaveFile );
IsLoaded(u32 waveIndex)48     bool IsLoaded( u32 waveIndex ) const
49     {
50         // if ( GetWaveFileForIndividual( waveIndex ) != NULL )
51         if ( GetWaveFile( waveIndex ) != NULL )
52         {
53             return true;
54         }
55         return false;
56     }
57 
58     bool HasIndividualLoadTable() const;
59 
60 private:
61     // 個別ロードされる波形のロード管理テーブル
62     struct IndividualLoadTable
63     {
64         const void* waveFile[1]; // 実際には、 InfoBlockBody.table.count だけ要素が並ぶ
65     };
66 
67     // アクセサ
GetWaveFileForWhole(u32 waveIndex)68     const void* GetWaveFileForWhole( u32 waveIndex ) const
69     {
70         u32 offset = m_pInfoBlockBody->GetOffsetFromFileBlockBody( waveIndex );
71         return ut::AddOffsetToPtr( &m_pHeader->GetFileBlock()->body, offset );
72     }
GetWaveFileForIndividual(u32 waveIndex)73     const void* GetWaveFileForIndividual( u32 waveIndex ) const
74     {
75         return m_pLoadTable->waveFile[ waveIndex ];
76     }
77 
78 
79     // データ
80     const WaveArchiveFile::FileHeader*      m_pHeader;
81     const WaveArchiveFile::InfoBlockBody*   m_pInfoBlockBody;
82     IndividualLoadTable*                    m_pLoadTable;
83 };
84 
85 } // namespace nw::snd::internal
86 } // namespace nw::snd
87 } // namespace nw
88 
89 
90 #endif /* NW_SND_WAVE_ARCHIVE_FILE_READER_H_ */
91 
92