1 /*---------------------------------------------------------------------------*
2 
3 Copyright (C) 2013-2014 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_SHOPPING_CART_H_
14 #define NN_EC_SHOPPING_CART_H_
15 
16 #include <nn/ec/ec_Cart.h>
17 
18 namespace nn { namespace ec {
19 
20 //! @addtogroup nn_ec_class
21 //! @{
22 
23 /*!
24 @brief Class for handling a shopping cart.
25 
26 @see        <a class="el" href="../../Doc/EcdkProgrammingManual/contents/Pages/Page_48711722.html#PageId_48924957">Programming Manual</a>
27 */
28 class ShoppingCart : public Cart
29 {
30 public:
31     NN_EC_DECLARE_ACCESSOR;
32     NN_EC_DECLARE_IMPL;
33 
34 public:
35     /*!
36 @brief Specifies the maximum number of downloadable content items that can be added to the shopping cart.
37     */
38     static const u32 AOC_NUM_MAX = 20;
39     /*!
40 @brief Specifies the maximum number of items that can be added to the shopping cart.
41     */
42     static const u32 ITEM_NUM_MAX = AOC_NUM_MAX;
43 
44 public:
45     /*!
46 @brief Instantiates the object.
47     */
48     ShoppingCart();
49 
50     /*!
51 @brief Destroys the object.
52     */
53     ~ShoppingCart();
54 
55     /*!
56 @brief Adds an item to the shopping cart.
57 
58 The reference counter of the added item is incremented by 1.
59 
60 @param[in] pItem  Specifies the item.
61 
62 @return The result of processing.
63 
64 @retval Result::IsSuccess Indicates success.
65 @retval ResultInvalidArgument  Indicates that an argument is invalid.
66 @retval     ResultInvalidData        Indicates that the data is invalid. (Item contains invalid data.)
67 @retval     ResultOutOfMemory       Insufficient memory.
68 @retval     ResultItemError                 Not an item that can be purchased.
69 @retval     ResultShoppingCartFull              The maximum number of items has been reached.
70 @retval     ResultShoppingCartAlreadyAdded      The item has already been added to the shopping cart.
71 @retval     ResultShoppingCartPartiallyAdded    Indicates that a portion of the item that includes multiple pieces of content has already been added to the shopping cart.
72     */
73     nn::Result AddItem(const Item* pItem);
74 
75     /*!
76 @brief Removes an item from the shopping cart.
77 
78 The reference counter of the deleted item is decremented by 1.
79 
80 @param[in] index  Specifies the index of the item to remove.
81 
82 @return The result of processing.
83 
84 @retval Result::IsSuccess Indicates success.
85 @retval     ResultNotFound      There is no item with that specified index.
86     */
87     nn::Result RemoveItem(u32 index);
88 
89     /*!
90 @brief Checks whether an item can be added to the shopping cart.
91 
92 An item that has not been purchased cannot be added again if it is already in the shopping cart.
93 
94 @param[in] pItem  Specifies the item.
95 
96 @return The result of processing.
97 
98 @retval     Result::IsSuccess               The item can be added.
99 @retval ResultInvalidArgument  Indicates that an argument is invalid.
100 @retval     ResultInvalidData        Indicates that the data is invalid. (Item contains invalid data.)
101 @retval     ResultItemError                 Not an item that can be purchased.
102 @retval     ResultShoppingCartFull              The maximum number of items has been reached.
103 @retval     ResultShoppingCartAlreadyAdded      The item has already been added to the shopping cart.
104 @retval     ResultShoppingCartPartiallyAdded    Indicates that a portion of the item that includes multiple pieces of content has already been added to the shopping cart.
105     */
106     nn::Result CheckItem(const Item* pItem) const;
107 
108     /*!
109 @brief Synchronizes the current license information.
110 
111 In some cases, an item that was added to the shopping cart can be purchased before synchronizing license information with <tt>@ref SynchronizeAocRights</tt>, but not after.
112 
113 If this occurs, call this function to remove all items that have not been purchased from the shopping cart.
114 The reference counter of the deleted item is decremented by 1.
115 
116 */
117     void SynchronizeCurrentRights();
118 
119     /*!
120 @brief Gets the total amount of the prices of all items in the shopping cart.
121 
122 @return Returns the total amount of the prices.
123     */
124     Money GetTotalAmount() const;
125 };
126 
127 //! @}
128 
129 }} // namespace nn::ec
130 
131 #endif // NN_EC_SHOPPING_CART_H_
132