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