IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 7, 2005, 10:58:51 AM (21 years ago)
Author:
desonia
Message:

modified psMetadata to use a special psMetadataType to signify duplicate
entries and added a flag to signify that duplicate entries are OK.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psMetadata.h

    r3341 r3381  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2005-02-28 23:34:10 $
     13*  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2005-03-07 20:58:50 $
    1515*
    1616*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2121#include <stdarg.h>
    2222#include <stdio.h>
     23#include <sys/types.h>
     24#include <regex.h>
    2325
    2426#include "psHash.h"
     
    3537 */
    3638typedef enum {
    37     PS_META_S32,                       ///< Primitive data.
    38     PS_META_F32,                       ///< Primitive data.
    39     PS_META_F64,                       ///< Primitive data.
    40     PS_META_BOOL,                       ///< Primitive data.
     39    PS_META_S32,                       ///< psS32 primitive data.
     40    PS_META_F32,                       ///< psF32 primitive data.
     41    PS_META_F64,                       ///< psF64 primitive data.
     42    PS_META_BOOL,                      ///< psBool primitive data.
    4143    PS_META_LIST,                      ///< List data (Stored as item.data.list).
    4244    PS_META_STR,                       ///< String data (Stored as item.data.V).
     
    4951    PS_META_ASTROM,                    ///< Astrometric coefficients (Stored as item.data.V).
    5052    PS_META_UNKNOWN,                   ///< Other data (Stored as item.data.V).
     53    PS_META_MULTI,                     ///< Used internally, do not create an metadata item of this type.
    5154    PS_META_NTYPE                      ///< Number of types. Must be last.
    5255} psMetadataType;
     
    7275typedef enum {
    7376    PS_META_DEFAULT = 0,               ///< default behaviour (duplicate entry is an error)
    74     PS_META_REPLACE = 0x10000          ///< allow entry to be replaced
     77    PS_META_REPLACE = 0x1000000,       ///< allow entry to be replaced
     78    PS_META_DUPLICATE_OK = 0x2000000   ///< allow duplicate entries
    7579} psMetadataFlags;
     80
     81#define PS_METADATA_FLAGS_MASK 0xFF000000
     82#define PS_METADATA_TYPE_MASK 0x00FFFFFF
    7683
    7784/** Metadata data structure.
     
    8895}
    8996psMetadata;
     97
     98/** Metadata iterator
     99 *
     100 *  Iterator for metadata.
     101 */
     102typedef struct
     103{
     104    psListIterator* iter;              ///< iterator for the psMetadata's psList
     105    regex_t* preg;                     ///< the subsetting regular expression
     106}
     107psMetadataIterator;
     108
    90109
    91110/** Metadata item data structure.
     
    134153);
    135154
     155/** Create a metadata item with specified string data.
     156 *
     157 *  Returns a fill psMetadataItem ready for insertion into the psMetadata
     158 *  struct.
     159 *
     160 * @return psMetadataItem* : Pointer metadata item.
     161 */
    136162psMetadataItem* psMetadataItemAllocStr(
    137     const char* name,
    138     const char* comment,
    139     const char* value
    140 );
    141 
     163    const char* name,                  ///< Name of metadata item.
     164    const char* comment,               ///< Comment for metadata item.
     165    const char* value                  ///< the value of the metadata item.
     166);
     167
     168/** Create a metadata item with specified psF32 data.
     169 *
     170 *  Returns a fill psMetadataItem ready for insertion into the psMetadata
     171 *  struct.
     172 *
     173 * @return psMetadataItem* : Pointer metadata item.
     174 */
    142175psMetadataItem* psMetadataItemAllocF32(
    143     const char* name,
    144     const char* comment,
    145     psF32 value
    146 );
    147 
     176    const char* name,                  ///< Name of metadata item.
     177    const char* comment,               ///< Comment for metadata item.
     178    psF32 value                        ///< the value of the metadata item.
     179);
     180
     181/** Create a metadata item with specified psF64 data.
     182 *
     183 *  Returns a fill psMetadataItem ready for insertion into the psMetadata
     184 *  struct.
     185 *
     186 * @return psMetadataItem* : Pointer metadata item.
     187 */
    148188psMetadataItem* psMetadataItemAllocF64(
    149     const char* name,
    150     const char* comment,
    151     psF64 value
    152 );
    153 
     189    const char* name,                  ///< Name of metadata item.
     190    const char* comment,               ///< Comment for metadata item.
     191    psF64 value                        ///< the value of the metadata item.
     192);
     193
     194/** Create a metadata item with specified psS32 data.
     195 *
     196 *  Returns a fill psMetadataItem ready for insertion into the psMetadata
     197 *  struct.
     198 *
     199 * @return psMetadataItem* : Pointer metadata item.
     200 */
    154201psMetadataItem* psMetadataItemAllocS32(
    155     const char* name,
    156     const char* comment,
    157     psS32 value
    158 );
    159 
     202    const char* name,                  ///< Name of metadata item.
     203    const char* comment,               ///< Comment for metadata item.
     204    psS32 value                        ///< the value of the metadata item.
     205);
     206
     207/** Create a metadata item with specified psBool data.
     208 *
     209 *  Returns a fill psMetadataItem ready for insertion into the psMetadata
     210 *  struct.
     211 *
     212 * @return psMetadataItem* : Pointer metadata item.
     213 */
    160214psMetadataItem* psMetadataItemAllocBool(
    161     const char* name,
    162     const char* comment,
    163     psBool value
     215    const char* name,                  ///< Name of metadata item.
     216    const char* comment,               ///< Comment for metadata item.
     217    psBool value                       ///< the value of the metadata item.
    164218);
    165219
     
    207261    psMetadata*  md,                   ///< Metadata collection to insert metadat item.
    208262    psMetadataItem*  item,             ///< Metadata item to be added.
    209     psS32 location                     ///< Location to be added.
     263    psS32 location,                    ///< Location to be added.
     264    psS32 flags                        ///< Options flag mask, see psMetadataFlags enum
    210265);
    211266
     
    218273psBool psMetadataAdd(
    219274    psMetadata* md,                    ///< Metadata collection to insert metadat item.
    220     psS32 where,                       ///< Location to be added.
     275    psS32 location,                    ///< Location to be added.
    221276    const char *name,                  ///< Name of metadata item.
    222     psMetadataType type,               ///< Type of metadata item.
     277    int type,                          ///< Type of metadata item (psMetadataType) and options (psMetadataFlags)
    223278    const char *comment,               ///< Comment for metadata item.
    224279    ...                                ///< Arguments for name formatting and metadata item data.
    225280);
    226281
    227 psBool psMetadataAddS32(psMetadata* md, psS32 where, const char* name,
     282#ifndef SWIG
     283/** Create and add a metadata item to metadata collection.
     284 *
     285 * Creates a new metadata item add to the metadata collection.
     286 *
     287 * @return bool: True for success, false for failure.
     288 */
     289psBool psMetadataAddV(
     290    psMetadata* md,                    ///< Metadata collection to insert metadat item.
     291    psS32 location,                    ///< Location to be added.
     292    const char *name,                  ///< Name of metadata item.
     293    int type,                          ///< Type of metadata item (psMetadataType) and options (psMetadataFlags)
     294    const char *comment,               ///< Comment for metadata item.
     295    va_list list                       ///< Arguments for name formatting and metadata item data.
     296);
     297#endif
     298
     299psBool psMetadataAddS32(psMetadata* md, psS32 location, const char* name,
    228300                        const char* comment, psS32 value);
    229 psBool psMetadataAddF32(psMetadata* md, psS32 where, const char* name,
     301psBool psMetadataAddF32(psMetadata* md, psS32 location, const char* name,
    230302                        const char* comment, psF32 value);
    231 psBool psMetadataAddF64(psMetadata* md, psS32 where, const char* name,
     303psBool psMetadataAddF64(psMetadata* md, psS32 location, const char* name,
    232304                        const char* comment, psF64 value);
    233 psBool psMetadataAddList(psMetadata* md, psS32 where, const char* name,
     305psBool psMetadataAddList(psMetadata* md, psS32 location, const char* name,
    234306                         const char* comment, psList* value);
    235 psBool psMetadataAddStr(psMetadata* md, psS32 where, const char* name,
     307psBool psMetadataAddStr(psMetadata* md, psS32 location, const char* name,
    236308                        const char* comment, const char* value);
    237 psBool psMetadataAddVector(psMetadata* md, psS32 where, const char* name,
     309psBool psMetadataAddVector(psMetadata* md, psS32 location, const char* name,
    238310                           const char* comment, psVector* value);
    239 psBool psMetadataAddImage(psMetadata* md, psS32 where, const char* name,
     311psBool psMetadataAddImage(psMetadata* md, psS32 location, const char* name,
    240312                          const char* comment, psImage* value);
    241 psBool psMetadataAddHash(psMetadata* md, psS32 where, const char* name,
     313psBool psMetadataAddHash(psMetadata* md, psS32 location, const char* name,
    242314                         const char* comment, psHash* value);
    243 psBool psMetadataAddLookupTable(psMetadata* md, psS32 where, const char* name,
     315psBool psMetadataAddLookupTable(psMetadata* md, psS32 location, const char* name,
    244316                                const char* comment, psLookupTable* value);
    245 psBool psMetadataAddUnknown(psMetadata* md, psS32 where, const char* name,
     317psBool psMetadataAddUnknown(psMetadata* md, psS32 location, const char* name,
    246318                            const char* comment, psPtr value);
    247319
     
    340412 * @return void* : Value of metadata item.
    341413 */
    342 void* psMetadataLookupPtr(
     414psPtr psMetadataLookupPtr(
    343415    psBool *status,                    ///< Status of lookup.
    344416    psMetadata* md,                    ///< Metadata collection to lookup metadata item.
     
    354426 */
    355427psMetadataItem* psMetadataGet(
    356     psMetadata*  md,           ///< Metadata collection to insert metadat item.
    357     psS32 where                ///< Location to be retrieved.
     428    psMetadata*  md,                   ///< Metadata collection to insert metadat item.
     429    psS32 location                     ///< Location to be retrieved.
     430);
     431
     432/** Creates a psMetadataIterator to iterate over the specified psMetadata.
     433 *
     434 *  Supports the subsetting of the metadata via keyword using regular
     435 *  expression.  If no regular expression is specified, iteration
     436 *  over the entire psMetadata is performed.
     437 *
     438 *  @return psMetadataIterator*        a new psMetadataIterator, of NULL if error occurred
     439 */
     440psMetadataIterator* psMetadataIteratorAlloc(
     441    psMetadata* md,                    ///< the psMetadata to iterate with
     442    int location,                      ///< the initial starting point (after subsetting).
     443    const char* regex
     444    ///< A regular expression for subsetting the psMetadata.  If NULL, no
     445    ///< subsetting is performed.
     446);
     447
     448/** Set the iterator of the psMetadat to a given position.  If location is
     449 *  invalid the iterator position is not changed.
     450 *
     451 *  @return psBool        TRUE if iterator successfully set, otherwise FALSE.
     452*/
     453psBool psMetadataIteratorSet(
     454    psMetadataIterator* iterator,      ///< psMetadata iterator
     455    int location                       ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
     456);
     457
     458/** Position the specified iterator to the next matching item in psMetadata,
     459 *  given the regular expression of the iterator
     460 *
     461 *  @return psPtr       the psMetadataItem at the original iterator position
     462 *                      or NULL if the iterator went past the end of the list.
     463 */
     464psMetadataItem* psMetadataGetAndIncrement(
     465    psMetadataIterator* iterator           ///< iterator to move
     466);
     467
     468/** Position the specified iterator to the previous matching item in psMetadata,
     469 *  given the regular expression of the iterator
     470 *
     471 *  @return psPtr       the psMetadataItem at the original iterator position
     472 *                      or NULL if the iterator went past the beginning of the
     473 *                      list.
     474 */
     475psMetadataItem* psMetadataGetAndDecrement(
     476    psMetadataIterator* iterator           ///< iterator to move
    358477);
    359478
Note: See TracChangeset for help on using the changeset viewer.