1 /*---------------------------------------------------------------------------*
2 
3 Copyright (C) Nintendo.  All rights reserved.
4 
5 These coded instructions, statements, and computer programs contain
6 proprietary information of Nintendo of America Inc. and/or Nintendo
7 Company Ltd., and are protected by Federal copyright law.  They may
8 not be disclosed to third parties or copied or duplicated in any form,
9 in whole or in part, without the prior written consent of Nintendo.
10 
11  *---------------------------------------------------------------------------*/
12 
13 #ifndef NN_EC_ITEM_LIST_H_
14 #define NN_EC_ITEM_LIST_H_
15 
16 #include <nn/ec/ec_Types.h>
17 #include <nn/ec/ec_Item.h>
18 
19 namespace nn { namespace ec {
20 
21 //! @addtogroup  nn_ec_class
22 //! @{
23 
24 /*!
25 @brief  Class for handling an item list.
26 */
27 class ItemList : public RootObject, private NonCopyable<ItemList>
28 {
29 public:
30     NN_EC_DECLARE_ACCESSOR;
31     NN_EC_DECLARE_IMPL;
32 
33 public:
34     /*!
35 @brief  Specifies an invalid index.
36 */
37     static const u32 INVALID_INDEX = 0xFFFFFFFF;
38 
39 public:
40     /*!
41 @brief  Instantiates an object.
42 */
43     ItemList();
44 
45     /*!
46 @brief  Destroys the object.
47 */
48     virtual ~ItemList();
49 
50     /*!
51 @brief  Clears the object.
52 
53 When this function is called, internally allocated memory is released. @n
54 In addition, the reference counter of the item in the list is decremented by 1.
55 */
56     void Clear();
57 
58     /*!
59 @brief  Downloads the icons of the items contained in the list.
60 
61 This function downloads the icons for the list items within the specified range. @n
62 For more information, see <tt>@ref Item::DownloadIconAsync</tt>.
63 
64 When downloading multiple icons at one time with this function, the tasks are added to the download queue as follows.
65 
66 Example: A list contains three items: a, b, and c, and the download queue contains three tasks: x, y, and z.
67 @li  HEAD: DL-Queue(Tx, Ty, Tz) == DownloadIconsAsync(0, 3, HEAD) => DL-Queue(Ta, Tb, Tc, Tx, Ty, Tz)
68 @li  TAIL: DL-Queue(Tx, Ty, Tz) == DownloadIconsAsync(0, 3, TAIL) => DL-Queue(Tx, Ty, Tz, Ta, Tb, Tc)
69 
70 @param[in] startIndex  Specifies the start position.
71 @param[in] num  Specifies the number to download.
72 @param[in] position  Specifies the position at which to add the download task. @n
73 The task is added to the front of the download queue by default.
74 
75 @return  The result of processing.
76 
77 @retval Result::IsSuccess  Indicates success.
78 @retval ResultInvalidData  Indicates that the data is invalid. (For example, the list has no items, or an item on the list has invalid data.)
79 @retval ResultOutOfMemory  Insufficient memory.
80 */
81     nn::Result DownloadIconsAsync(u32 startIndex = 0, u32 num = 0xFFFFFFFF, QueuePosition position = QUEUE_POSITION_HEAD);
82 
83     /*!
84 @brief  Gets an item.
85 
86 The reference counter of the item obtained with this function is decremented by 1 when <tt>@ref Clear</tt> or the destructor is called. @n
87 Make note of the persistence of the item.
88 
89 @param[in] index  Specifies the index in the list.
90 
91 @return  Returns the item. @n
92 If the specified index is out of bounds, <tt>NULL</tt> is returned.
93 */
94     Item* GetItem(u32 index);
95 
96     /*!
97 @brief  Gets an item.
98 
99 The reference counter of the item obtained with this function is decremented by 1 when <tt>@ref Clear</tt> or the destructor is called. @n
100 Make note of the persistence of the item.
101 
102 @param[in] index  Specifies the index in the list.
103 
104 @return  Returns the item. @n
105 If the specified index is out of bounds, <tt>NULL</tt> is returned.
106 */
107     const Item* GetItem(u32 index) const;
108 
109     /*!
110 @brief  Gets the number of items contained in the list.
111 
112 @return  Returns the number of items.
113 */
114     u32 GetNumItems() const;
115 
116     /*!
117 @brief  Gets the index of the item in the list.
118 
119 @param[in] pItem  Specifies the item.
120 
121 @return  Returns the index. @n
122 If the specified item is invalid or does not exist in the list, <tt>@ref INVALID_INDEX</tt> is returned.
123 */
124     u32 GetIndex(const Item* pItem) const;
125 
126 protected:
127     //
128     NN_EC_IMPL;
129 };
130 
131 //! @}
132 
133 }} // namespace nn::ec
134 
135 #endif // NN_EC_ITEM_LIST_H_
136