Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

List.h

Go to the documentation of this file.
00001 /** 
00002  *  @file   List.h
00003  *
00004  *  @brief      Creates a doubly linked list. It works as utils for other
00005  *              modules
00006  *
00007  *
00008  *  @ver        02.00.00.68_beta1
00009  *  
00010  *  ============================================================================
00011  *  
00012  *  Copyright (c) 2008-2009, Texas Instruments Incorporated
00013  *
00014  *  Redistribution and use in source and binary forms, with or without
00015  *  modification, are permitted provided that the following conditions
00016  *  are met:
00017  *  
00018  *  *  Redistributions of source code must retain the above copyright
00019  *     notice, this list of conditions and the following disclaimer.
00020  *  
00021  *  *  Redistributions in binary form must reproduce the above copyright
00022  *     notice, this list of conditions and the following disclaimer in the
00023  *     documentation and/or other materials provided with the distribution.
00024  *  
00025  *  *  Neither the name of Texas Instruments Incorporated nor the names of
00026  *     its contributors may be used to endorse or promote products derived
00027  *     from this software without specific prior written permission.
00028  *  
00029  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00030  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00031  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00032  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00033  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00034  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00035  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00036  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00037  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00038  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00039  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00040  *  Contact information for paper mail:
00041  *  Texas Instruments
00042  *  Post Office Box 655303
00043  *  Dallas, Texas 75265
00044  *  Contact information: 
00045  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
00046  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
00047  *  ============================================================================
00048  *  
00049  */
00050 
00051 
00052 #ifndef LIST_H_0XB734
00053 #define LIST_H_0XB734
00054 
00055 
00056 
00057 #if defined (__cplusplus)
00058 extern "C" {
00059 #endif
00060 
00061 
00062 /* =============================================================================
00063  *  Macros and types
00064  * =============================================================================
00065  */
00066 /*!
00067  *  @def    List_traverse
00068  *  @brief  Traverse the full list till the last element.
00069  */
00070 #define List_traverse(x,y) for(x = (List_Elem *)((List_Object *)y)->elem.next; \
00071                                (UInt32) x != (UInt32)&((List_Object *)y)->elem;\
00072                                 x = x->next)
00073 
00074 /*!
00075  *  @brief  Structure defining object for the list element.
00076  */
00077 typedef struct List_Elem_tag {
00078     struct List_Elem_tag *  next; /*!< Pointer to the next element */
00079     struct List_Elem_tag *  prev; /*!< Pointer to the previous element */
00080 } List_Elem;
00081 
00082 /*!
00083  *  @brief  Structure defining object for the list.
00084  */
00085 typedef struct List_Object_tag {
00086     List_Elem            elem;
00087     /*!< Head pointing to next element */
00088 } List_Object;
00089 
00090 /*! @brief Defines List handle type */
00091 typedef List_Object * List_Handle;
00092 
00093 /*!
00094  *  @brief  Structure defining params for the list.
00095  */
00096 typedef struct List_Params_tag {
00097     UInt32        temp;
00098 } List_Params;
00099 
00100 
00101 /* =============================================================================
00102  *  APIs
00103  * =============================================================================
00104  */
00105 /*!
00106  *  @brief      Initialize this config-params structure with supplier-specified
00107  *              defaults before instance creation.
00108  *
00109  *  @param      params  Instance config-params structure.
00110  *
00111  *  @sa         List_create
00112  */
00113 Void List_Params_init (List_Params * params);
00114 
00115 /*!
00116  *  @brief      Function to create a list object.
00117  *
00118  *  @param      params  Pointer to list creation parameters. If NULL is passed,
00119  *                      default parameters are used.
00120  *
00121  *  @retval     List-handle Handle to the list object
00122  *
00123  *  @sa         List_delete
00124  */
00125 List_Handle List_create (List_Params * params, Error_Block *eb);
00126 
00127 /*!
00128  *  @brief      Function to delete a list object.
00129  *
00130  *  @param      handlePtr  Pointer to the list handle
00131  *
00132  *  @sa         List_delete
00133  */
00134 Void List_delete (List_Handle * handlePtr);
00135 
00136 /*!
00137  *  @brief      Function to construct a list object. This function is used when
00138  *              memory for the list object is not to be allocated by the List
00139  *              API.
00140  *
00141  *  @param      obj     Pointer to the list object to be constructed
00142  *  @param      params  Pointer to list construction parameters. If NULL is
00143  *                      passed, default parameters are used.
00144  *
00145  *  @sa         List_destruct
00146  */
00147 Void List_construct (List_Object * obj, List_Params * params);
00148 
00149 /*!
00150  *  @brief      Function to destruct a list object.
00151  *
00152  *  @param      obj  Pointer to the list object to be destructed
00153  *
00154  *  @sa         List_construct
00155  */
00156 Void List_destruct (List_Object * obj);
00157 
00158 /*!
00159  *  @brief      Function to clear element contents.
00160  *
00161  *  @param      elem Element to be cleared
00162  *
00163  *  @sa
00164  */
00165 Void List_elemClear (List_Elem * elem);
00166 
00167 /*!
00168  *  @brief      Function to check if list is empty.
00169  *
00170  *  @param      handle  Pointer to the list
00171  *
00172  *  @retval     TRUE    List is empty
00173  *  @retval     FALSE   List is not empty
00174  *
00175  *  @sa
00176  */
00177 Bool List_empty (List_Handle handle);
00178 
00179 /*!
00180  *  @brief      Function to get first element of List.
00181  *
00182  *  @param      handle  Pointer to the list
00183  *
00184  *  @retval     NULL          Operation failed
00185  *  @retval     Valid-pointer Pointer to first element
00186  *
00187  *  @sa         List_put
00188  */
00189 Ptr List_get (List_Handle handle);
00190 
00191 /*!
00192  *  @brief      Function to insert element at the end of List.
00193  *
00194  *  @param      handle  Pointer to the list
00195  *  @param      elem    Element to be inserted
00196  *
00197  *  @sa         List_get
00198  */
00199 Void List_put (List_Handle handle, List_Elem * elem);
00200 
00201 /*!
00202  *  @brief      Function to traverse to the next element in the list (non
00203  *              atomic)
00204  *
00205  *  @param      handle  Pointer to the list
00206  *  @param      elem    Pointer to the current element
00207  *
00208  *  @retval     NULL          Operation failed
00209  *  @retval     Valid-pointer Pointer to next element
00210  *
00211  *  @sa         List_prev
00212  */
00213 Ptr List_next (List_Handle handle, List_Elem * elem);
00214 
00215 /*!
00216  *  @brief      Function to traverse to the previous element in the list (non
00217  *              atomic)
00218  *
00219  *  @param      handle  Pointer to the list
00220  *  @param      elem    Pointer to the current element
00221  *
00222  *  @retval     NULL          Operation failed
00223  *  @retval     Valid-pointer Pointer to previous element
00224  *
00225  *  @sa         List_next
00226  */
00227 Ptr List_prev (List_Handle handle, List_Elem * elem);
00228 
00229 /*!
00230  *  @brief      Function to insert element before the existing element
00231  *              in the list.
00232  *
00233  *  @param      handle  Pointer to the list
00234  *  @param      newElem Element to be inserted
00235  *  @param      curElem Existing element before which new one is to be inserted
00236  *
00237  *  @sa         List_remove
00238  */
00239 Void List_insert (List_Handle handle, List_Elem * newElem, List_Elem * curElem);
00240 
00241 /*!
00242  *  @brief      Function to removes element from the List.
00243  *
00244  *  @param      handle    Pointer to the list
00245  *  @param      elem      Element to be removed
00246  *
00247  *  @sa         List_insert
00248  */
00249 Void List_remove (List_Handle handle, List_Elem * elem);
00250 
00251 /*!
00252  *  @brief      Function to put the element before head.
00253  *
00254  *  @param      handle    Pointer to the list
00255  *  @param      elem      Element to be added at the head
00256  *
00257  *  @sa         List_put
00258  */
00259 Void List_putHead (List_Handle handle, List_Elem * elem);
00260 
00261 /*!
00262  *  @brief      Get element from front of List (non-atomic)
00263  *
00264  *  @param      handle  Pointer to the list
00265  *
00266  *  @retval     NULL          Operation failed
00267  *  @retval     Valid-pointer Pointer to removed element
00268  *
00269  *  @sa         List_enqueue, List_enqueueHead
00270  */
00271 Ptr List_dequeue (List_Handle handle);
00272 
00273 /*!
00274  *  @brief      Put element at end of List (non-atomic)
00275  *
00276  *  @param      handle  Pointer to the list
00277  *  @param      elem    Element to be put
00278  *
00279  *  @sa         List_dequeue
00280  */
00281 Void List_enqueue (List_Handle handle, List_Elem * elem);
00282 
00283 /*!
00284  *  @brief      Put element at head of List (non-atomic)
00285  *
00286  *  @param      handle   Pointer to the list
00287  *  @param      elem     Element to be added
00288  *
00289  *  @sa         List_dequeue
00290  */
00291 Void List_enqueueHead (List_Handle handle, List_Elem * elem);
00292 
00293 
00294 #if defined (__cplusplus)
00295 }
00296 #endif /* defined (__cplusplus) */
00297 
00298 
00299 #endif /* LIST_H_0XB734 */

Generated on Mon Mar 14 11:59:45 2011 for Syslink by  doxygen 1.4.4