1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_PlayerHeapDataManager.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: $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_SND_PLAYER_HEAP_DATA_MANAGER_H_
19 #define NW_SND_PLAYER_HEAP_DATA_MANAGER_H_
20 
21 #include <nw/snd/snd_DisposeCallback.h>
22 #include <nw/snd/snd_SoundArchiveLoader.h>
23 #include <nw/snd/snd_SoundArchive.h>
24 
25 namespace nw {
26 namespace snd {
27 namespace internal {
28 
29 class PlayerHeapDataManager : public internal::driver::DisposeCallback,
30                               public internal::SoundArchiveLoader
31 {
32 public:
33     PlayerHeapDataManager();
34     virtual ~PlayerHeapDataManager();
35 
36     void Initialize( const SoundArchive* arc );
37     void Finalize();
38 
39     const void* SetFileAddress( SoundArchive::FileId fileId, const void* address );
40     const void* GetFileAddress( SoundArchive::FileId ) const;
41 
42     static const int FILE_ADDRESS_COUNT = 1 + 4 + 4;
43 
44 protected:
45     virtual void InvalidateData( const void* start, const void* end );
46     virtual const void* SetFileAddressToTable(
47             SoundArchive::FileId, const void* address );
48     virtual const void* GetFileAddressFromTable( SoundArchive::FileId fileId ) const;
49     virtual const void* GetFileAddressImpl( SoundArchive::FileId fileId ) const;
50 
51 private:
52     struct FileAddress
53     {
54         SoundArchive::FileId fileId;
55         const void* address;
56     };
57 
58     FileAddress m_FileAddress[FILE_ADDRESS_COUNT];
59         // NW4C-1.3.0 現在、ひとつのサウンドを鳴らすのに必要なファイルは、最大9個
60         // (== bcseq + 4 * bcbnk + 4 * bcwar)。
61     bool m_IsInitialized;
62     bool m_IsFinalized;
63 };
64 
65 } // namespace nw::snd::internal
66 } // namespace nw::snd
67 } // namespace nw
68 
69 
70 #endif /* NW_SND_PLAYER_HEAP_DATA_MANAGER_H_ */
71 
72