1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_PlayerHeap.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_PLAYER_HEAP_H_
19 #define NW_SND_PLAYER_HEAP_H_
20 
21 #include <nw/snd/snd_SoundMemoryAllocatable.h>
22 #include <nw/ut/ut_LinkList.h>
23 
24 namespace nw {
25 namespace snd {
26 
27 /* ========================================================================
28         type declaration
29    ======================================================================== */
30 
31 class SoundPlayer;
32 
33 namespace internal {
34 
35 class BasicSound;
36 
37 /* ========================================================================
38         class defition
39    ======================================================================== */
40 
41 class PlayerHeap : public SoundMemoryAllocatable
42 {
43 public:
44     PlayerHeap();
45     virtual ~PlayerHeap();
46 
AttachSoundPlayer(SoundPlayer * player)47     void AttachSoundPlayer( SoundPlayer* player ) { m_pPlayer = player; }
48 
49     void AttachSound( BasicSound* sound );
50     void DetachSound( BasicSound* sound );
51 
52     bool Create( void* startAddress, size_t size );
53     void Destroy();
54 
55     // メモリブロックを確保する
56     virtual void* Alloc( size_t size );
57 
58     // 確保したメモリブロックを全て解放する
59     void Clear();
60 
61     // ヒープが有効かどうかを調べる
IsValid()62     bool IsValid() const { return m_pAllocAddress != NULL; }
63 
64     // ヒープの空き容量を取得する
65     size_t GetFreeSize() const;
66 
67 private:
68     BasicSound* m_pSound;
69     SoundPlayer* m_pPlayer;
70 
71     void* m_pStartAddress;
72     void* m_pEndAddress;
73     void* m_pAllocAddress;
74 
75 public:
76     ut::LinkListNode m_Link; // NW_UT_INIT_LIST のためにpublic
77 };
78 
79 
80 } // namespace nw::snd::internal
81 } // namespace nw::snd
82 } // namespace nw
83 
84 
85 #endif /* NW_SND_PLAYER_HEAP_H_ */
86 
87