1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     fnd_DetailList.h
4   Copyright (C)2009 Nintendo Co., Ltd.  All rights reserved.
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   $Rev: 12449 $
11  *---------------------------------------------------------------------------
12 
13 
14 */
15 
16 #ifndef NN_FND_DETAIL_FND_DETAIL_LIST_H_
17 #define NN_FND_DETAIL_FND_DETAIL_LIST_H_
18 
19 #include <stddef.h>
20 #include <nn/types.h>
21 #include <nn/assert.h>
22 #include <nn/fnd/detail/fnd_DetailHeapHead.h>
23 
24 #ifdef __cplusplus
25 
26 namespace nn { namespace fnd { namespace detail {
27 //
28 
29 /*---------------------------------------------------------------------------*
30   Name:         NN_OS_INIT_LIST
31   Description:  Macro to initialize list structures. The actual initialization is performed by the NNSFndInitList function.
32 
33                 With this macro, the offset is found using the "offsetof" macro from the specified structure name and NNSFndLink type member variable name and passed to the NNSFndInitList function.
34 
35 
36   Arguments:    list:       Pointer to the link structure.
37                 structName: Structure name of object you wish to link in the list.
38                 linkName:   The NNSFndLink type member variable name used in this object link.
39 
40   Returns:      None.
41  *---------------------------------------------------------------------------
42 
43 
44 
45 */
46 
47 #define NN_OS_INIT_LIST(list, structName, linkName) \
48             InitList(list, offsetof(structName, linkName))
49 
50 
51 /*---------------------------------------------------------------------------*
52     Function Prototypes
53  *---------------------------------------------------------------------------
54 */
55 
56 void    InitList(
57                 NNSFndList*             list,
58                 u16                     offset);
59 
60 void    AppendListObject(
61                 NNSFndList*             list,
62                 void*                   object);
63 
64 void    PrependListObject(
65                 NNSFndList*             list,
66                 void*                   object);
67 
68 void    InsertListObject(
69                 NNSFndList*             list,
70                 void*                   target,
71                 void*                   object);
72 
73 void    RemoveListObject(
74                 NNSFndList*             list,
75                 void*                   object);
76 
77 void*   GetNextListObject(
78                 const NNSFndList*       list,
79                 const void*             object);
80 
81 void*   GetPrevListObject(
82                 const NNSFndList*       list,
83                 const void*             object);
84 
85 void*   GetNthListObject(
86                 const NNSFndList*       list,
87                 u16                     index);
88 
89 
90 /*---------------------------------------------------------------------------*
91   Name:         GetListSize
92   Description:  Gets the number of objects registered to the list specified by the argument.
93 
94   Arguments:    list: Pointer to the list structure.
95   Returns:      Returns the number of objects registered to the specified list.
96  *---------------------------------------------------------------------------
97 
98 
99 */
100 inline u16
GetListSize(const NNSFndList * list)101 GetListSize( const NNSFndList* list )
102 {
103     NN_TASSERT_( list );
104 
105     return list->numObjects;
106 }
107 
108 /* NN_OS_LIST_H_ */
109 //
110 }}} // namespace nn::os
111 
112 #endif // __cplusplus
113 
114 #endif
115 
116