1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     fnd_MemoryRange.h
4 
5   Copyright (C)2009 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 31054 $
14  *---------------------------------------------------------------------------*/
15 
16 /*!@file
17   @brief    メモリ領域の範囲を表すクラスです。
18  */
19 
20 #ifndef NN_FND_FND_MEMORYRANGE_H_
21 #define NN_FND_FND_MEMORYRANGE_H_
22 
23 #include <nn/types.h>
24 
25 #include <nn/Assert.h>
26 
27 #ifdef __cplusplus
28 
29 
30 namespace nn { namespace fnd {
31 
32 /*!
33     @brief    メモリ領域の範囲を表すクラスです。
34  */
35 class MemoryRange
36 {
37 public:
38 
MemoryRange()39     MemoryRange() {}
40 
41     /*!
42         @brief      メモリ領域の範囲を表すオブジェクトを構築します。
43 
44         @param[in] begin    先頭アドレスを表します。
45 
46         @param[in] end      末尾アドレスを表します。領域内の最後のアドレス+4 の位置を指定します。
47     */
MemoryRange(uptr begin,uptr end)48     MemoryRange(uptr begin, uptr end) : m_Begin(begin), m_End(end) { NN_TASSERT_(m_Begin <= m_End); }
49 
50     /*!
51         @brief      メモリ領域の範囲を初期化します。
52 
53         @param[in] begin    先頭アドレスを表します。
54 
55         @param[in] end      末尾アドレスを表します。領域内の最後のアドレス+4 の位置を指定します。
56     */
Initialize(uptr begin,uptr end)57     void Initialize(uptr begin, uptr end) { m_Begin = begin; m_End = end; NN_TASSERT_(m_Begin <= m_End); }
58 
59     /*!
60         @brief      先頭アドレスを返します。
61     */
GetAddress()62     uptr GetAddress() const { return m_Begin; }
63 
64     /*!
65         @brief      末尾のアドレスを返します。
66 
67                     先頭アドレス + 領域の大きさ の位置であり、領域内の最後のアドレス+4 の位置を表しています。
68     */
GetEndAddress()69     uptr GetEndAddress() const { return m_End; }
70 
71     /*!
72         @brief          範囲の大きさを返します。
73 
74         @return         メモリブロックの大きさ
75     */
GetSize()76     size_t GetSize() const { return m_End - m_Begin; }
77 
78 private:
79     uptr m_Begin;
80     uptr m_End;
81 };
82 
83 }}
84 
85 #endif
86 
87 #endif
88