graphicscomposition/openwfcompositionengine/common/include/owfarray.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 /* Copyright (c) 2009 The Khronos Group Inc.
       
     2  *
       
     3  * Permission is hereby granted, free of charge, to any person obtaining a
       
     4  * copy of this software and/or associated documentation files (the
       
     5  * "Materials"), to deal in the Materials without restriction, including
       
     6  * without limitation the rights to use, copy, modify, merge, publish,
       
     7  * distribute, sublicense, and/or sell copies of the Materials, and to
       
     8  * permit persons to whom the Materials are furnished to do so, subject to
       
     9  * the following conditions:
       
    10  *
       
    11  * The above copyright notice and this permission notice shall be included
       
    12  * in all copies or substantial portions of the Materials.
       
    13  *
       
    14  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
       
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
       
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
       
    20  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
       
    21  */
       
    22 #ifndef OWFARRAY_H_
       
    23 #define OWFARRAY_H_
       
    24 
       
    25 #include "owftypes.h"
       
    26 
       
    27 
       
    28 #ifdef __cplusplus
       
    29 extern "C"
       
    30 {
       
    31 #endif
       
    32 
       
    33 
       
    34 typedef void*                 OWF_ARRAY_ITEM;
       
    35 
       
    36 typedef struct {
       
    37     OWF_ARRAY_ITEM* items;
       
    38     OWFint          capacity;
       
    39     OWFint          length;
       
    40 } OWF_ARRAY;
       
    41 
       
    42 /*!
       
    43  *  Initialize array object
       
    44  *
       
    45  *  \param array Array object
       
    46  */
       
    47 OWF_API_CALL void
       
    48 OWF_Array_Initialize(OWF_ARRAY* array);
       
    49 
       
    50 /*!
       
    51  *  Reset array. Frees resources allocated by the array.
       
    52  *  Doesn't destroy the actual contents (managed
       
    53  *  by the array user). The array can be safely reused afterwards.
       
    54  *
       
    55  *  \param array Array object
       
    56  */
       
    57 OWF_API_CALL void
       
    58 OWF_Array_Reset(OWF_ARRAY* array);
       
    59 
       
    60 /*!
       
    61  *  Destroy array. Free all resources allocated
       
    62  *  by the array.
       
    63  *
       
    64  *  \param array Array object
       
    65  */
       
    66 OWF_API_CALL void
       
    67 OWF_Array_Destroy(OWF_ARRAY* array);
       
    68 
       
    69 /*!
       
    70  *  Append item to array
       
    71  *
       
    72  *  \param array Array object
       
    73  *  \param item Item to add
       
    74  *
       
    75  *  \return OWF_TRUE if the operation succeeded, OWF_FALSE otherwise
       
    76  */
       
    77 OWF_API_CALL OWFboolean
       
    78 OWF_Array_AppendItem(OWF_ARRAY* array,
       
    79                       OWF_ARRAY_ITEM item);
       
    80 
       
    81 /*!
       
    82  *  Insert item into the array
       
    83  *
       
    84  *  \param array Array object
       
    85  *  \param position Where the item should be inserted at
       
    86  *  \param item Item to insert
       
    87  *
       
    88  *  \return OWF_TRUE if the operation succeeded, OWF_FALSE otherwise
       
    89  */
       
    90 OWF_API_CALL OWFboolean
       
    91 OWF_Array_InsertItem(OWF_ARRAY*    array,
       
    92                      OWFint position,
       
    93                      OWF_ARRAY_ITEM item);
       
    94 
       
    95 /*!
       
    96  *  Remove item (by value) from the array
       
    97  *
       
    98  *  \param array Array object
       
    99  *  \param item Item to remove
       
   100  *
       
   101  *  \return Removed item or NULL if the item is invalid.
       
   102  *
       
   103  */
       
   104 OWF_API_CALL OWF_ARRAY_ITEM
       
   105 OWF_Array_RemoveItem(OWF_ARRAY* array,
       
   106                       OWF_ARRAY_ITEM item);
       
   107 
       
   108 /*!
       
   109  *  Remove item (by index) from the array
       
   110  *
       
   111  *  \param array Array object
       
   112  *  \param position Index of the item to remove
       
   113  *
       
   114  *  \return Removed item or NULL if the index is out of bounds.
       
   115  */
       
   116 OWF_API_CALL OWF_ARRAY_ITEM
       
   117 OWF_Array_RemoveItemAt(OWF_ARRAY* array,
       
   118                           OWFint position);
       
   119 
       
   120 /*!
       
   121  *  Get item from array
       
   122  *
       
   123  *  \param array Array object
       
   124  *  \param position Index of the item to fetch (0..array.length-1)
       
   125  *
       
   126  *  \return Item or NULL, if the position argument is out of bounds.
       
   127  *
       
   128  */
       
   129 OWF_API_CALL OWF_ARRAY_ITEM
       
   130 OWF_Array_GetItemAt(OWF_ARRAY* array,
       
   131                     OWFint position);
       
   132 
       
   133 
       
   134 #ifdef __cplusplus
       
   135 }
       
   136 #endif
       
   137 
       
   138 #endif