IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2005, 3:04:01 PM (21 years ago)
Author:
desonia
Message:

added some helpful functionality to help SWIG.

Location:
trunk/psLib/src/collections
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psArray.c

    r3115 r3165  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-03 00:54:10 $
     11 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-02-09 01:04:01 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    157157    return in;
    158158}
     159
     160/// Set an element in the array.
     161psBool psArraySet(psArray* in,                       ///< input array to set element in
     162                  psU32 position,                    ///< the element position to set
     163                  void* value)                       ///< the value to set it to
     164{
     165    if (in == NULL)
     166    {
     167        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     168                PS_ERRORTEXT_psArray_ARRAY_NULL);
     169        return false;
     170    }
     171
     172    if (position >= in->nalloc)
     173    {
     174        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     175                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     176                position, in->nalloc);
     177        return false;
     178    }
     179
     180    psFree(in->data[position]);
     181    in->data[position] = value;
     182
     183    return true;
     184}
     185
     186/// Get an element in the array.
     187void* psArrayGet(psArray* in, psU32 position )
     188{
     189    if (in == NULL) {
     190        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     191                PS_ERRORTEXT_psArray_ARRAY_NULL);
     192        return NULL;
     193    }
     194
     195    if (position >= in->nalloc) {
     196        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     197                PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC,
     198                position, in->nalloc);
     199        return NULL;
     200    }
     201
     202    return in->data[position];
     203}
     204
     205
     206
     207
  • trunk/psLib/src/collections/psArray.h

    r3115 r3165  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-02-03 00:54:10 $
     14 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-02-09 01:04:01 $
    1616 *
    1717 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    126126);
    127127
     128/** Set an element in the array.  If the current element is non-NULL, the old
     129 *  element is freed.
     130 *
     131 *  @return psBool  TRUE if the element was set successfully, otherwise FALSE
     132 */
     133psBool psArraySet(
     134    psArray* in,                       ///< input array to set element in
     135    psU32 position,                    ///< the element position to set
     136    void* value                        ///< the value to set it to
     137);
     138
     139/** Get an element from the array.
     140 *
     141 *  @return void*   the element at given position.
     142 */
     143void* psArrayGet(
     144    psArray* in,                       ///< input array to get element from
     145    psU32 position                     ///< the element position to get
     146);
     147
    128148/// @}
    129149
  • trunk/psLib/src/collections/psCollectionsErrors.dat

    r3107 r3165  
    1010psArray_REALLOC_NULL                   psArrayRealloc must be given a non-NULL psArray to resize.
    1111psArray_ARRAY_NULL                     Specified psArray can not be NULL.
     12psArray_POSITION_BEYOND_NALLOC         Specified position, %d, is greater than the allocated size of the array, %d.
    1213#
    1314psVector_REALLOC_NULL                  psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown.
  • trunk/psLib/src/collections/psCollectionsErrors.h

    r3107 r3165  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-02-02 20:21:48 $
     9 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-02-09 01:04:01 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3232#define PS_ERRORTEXT_psArray_REALLOC_NULL "psArrayRealloc must be given a non-NULL psArray to resize."
    3333#define PS_ERRORTEXT_psArray_ARRAY_NULL "Specified psArray can not be NULL."
     34#define PS_ERRORTEXT_psArray_POSITION_BEYOND_NALLOC "Specified position, %d, is greater than the allocated size of the array, %d."
    3435#define PS_ERRORTEXT_psVector_REALLOC_NULL "psVectorRealloc must a given a non-NULL psVector to resize.  Desired datatype unknown."
    3536#define PS_ERRORTEXT_psVector_NOT_A_VECTOR "The input psVector must have a vector dimension type."
Note: See TracChangeset for help on using the changeset viewer.