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

psMetadata.h

Go to the documentation of this file.
00001 /** @file  psMetadata.h
00002 *
00003 *  @brief Contains metadata struuctures, enumerations and functions prototypes
00004 *
00005 *  This file defines metadata item, metadata type, metadata flags, metadata containers, and function
00006 *  prototypes necessary creating psLib metadata APIs
00007 *
00008 *  @ingroup Metadata
00009 *
00010 *  @author Robert DeSonia, MHPCC
00011 *  @author Ross Harman, MHPCC
00012 *
00013 *  @version $Revision: 1.1.1.1 $ $Name:  $
00014 *  @date $Date: 2005/10/14 00:32:52 $
00015 *
00016 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00017 */
00018 #ifndef PS_METADATA_H
00019 #define PS_METADATA_H
00020 
00021 #include <stdarg.h>
00022 #include <stdio.h>
00023 #include <sys/types.h>
00024 #include <regex.h>
00025 
00026 #include "psHash.h"
00027 #include "psList.h"
00028 #include "psTime.h"
00029 #include "psLookupTable.h"
00030 
00031 /// @addtogroup Metadata
00032 /// @{
00033 
00034 #define PS_DATA_IS_PRIMITIVE(TYPE) \
00035 (TYPE == PS_DATA_S32 || \
00036  TYPE == PS_DATA_F32 || \
00037  TYPE == PS_DATA_F64 || \
00038  TYPE == PS_DATA_BOOL)
00039 
00040 #define PS_DATA_PRIMITIVE_TYPE(DATATYPE) ( \
00041         (DATATYPE==PS_DATA_S32 || DATATYPE==PS_DATA_F32 || \
00042          DATATYPE==PS_DATA_F64 || DATATYPE==PS_DATA_BOOL) ? DATATYPE : 0)
00043 
00044 
00045 /** Option flags for psMetadata functions
00046  *
00047  *  Enumeration for the modification of the behaviour in psMetadataAddItem.
00048  *
00049  *  @see psMetadataAddItem
00050  */
00051 typedef enum {
00052     PS_META_DEFAULT = 0,               ///< default behaviour (duplicate entry is an error)
00053     PS_META_REPLACE = 0x1000000,       ///< allow entry to be replaced
00054     PS_META_DUPLICATE_OK = 0x2000000,  ///< allow duplicate entries
00055     PS_META_NULL = 0x4000000           ///< psMetadataItem.data is a NULL value
00056 } psMetadataFlags;
00057 
00058 #define PS_METADATA_FLAGS_MASK 0xFF000000
00059 #define PS_METADATA_TYPE_MASK 0x00FFFFFF
00060 
00061 /** Metadata data structure.
00062  *
00063  *  Struct for holding metadata items. Metadata items are held in two
00064  *  containers. The first employs a doubly-linked list to preserve the order
00065  *  of the metadata. The second container employs a hash table which
00066  *  allows fast lookup when given a metadata keyword.
00067  */
00068 typedef struct
00069 {
00070     psList*  list;                     ///< Metadata in linked-list
00071     psHash*  hash;                     ///< Metadata in a hash table
00072     void *lock;                        ///< Optional lock for thread safety
00073 }
00074 psMetadata;
00075 
00076 /** Metadata iterator
00077  *
00078  *  Iterator for metadata.
00079  */
00080 typedef struct
00081 {
00082     psListIterator* iter;              ///< iterator for the psMetadata's psList
00083     regex_t* regex;                    ///< the subsetting regular expression
00084 }
00085 psMetadataIterator;
00086 
00087 /** Metadata item data structure.
00088  *
00089  * Struct for maintaining metadata items of varying types. It also contains
00090  * information about the item name, flags, comments, and other items with the same name.
00091  */
00092 typedef struct
00093 {
00094     const psS32 id;                    ///< Unique ID for metadata item.
00095     psString name;                     ///< Name of metadata item.
00096     psDataType type;                   ///< Type of metadata item.
00097     union {
00098         psBool B;                      ///< boolean data
00099         psS8 S8;                       ///< Signed 8-bit integer data.
00100         psS16 S16;                     ///< Signed 16-bit integer data.
00101         psS32 S32;                     ///< Signed 32-bit integer data.
00102         psU8 U8;                       ///< Unsigned 8-bit integer data.
00103         psU16 U16;                     ///< Unsigned 16-bit integer data.
00104         psU32 U32;                     ///< Unsigned 32-bit integer data.
00105         psF32 F32;                     ///< Single-precision float data.
00106         psF64 F64;                     ///< Double-precision float data.
00107         psList *list;                  ///< List data.
00108         psMetadata *md;                ///< Metadata data.
00109         psPtr V;                       ///< Pointer to other type of data.
00110     } data;                            ///< Union for data types.
00111     psString comment;                  ///< Optional comment ("", not NULL).
00112 }
00113 psMetadataItem;
00114 
00115 /** Create a metadata item.
00116  *
00117  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00118  *  struct. The name argument specifies the name to use for this item, and
00119  *  may include sprintf formatting codes. The format entry specifies both
00120  *  the metadata type and optional flags and is created by bit-wise or of the
00121  *  appropriate type and flag. The comment argument is a fixed string used to
00122  *  comment the metadata item. The arguments to the name formatting codes and
00123  *  the metadata itself are passed as arguments following the comment string.
00124  *  The data must be a pointer for any of the elements stored in data.void.
00125  *  The argument list must be interpreted appropriately by the va_list
00126  *  operators in the function specified size and type.
00127  *
00128  * @return psMetadataItem* : Pointer metadata item.
00129  */
00130 psMetadataItem* psMetadataItemAlloc(
00131     const char *name,                  ///< Name of metadata item.
00132     psDataType type,                   ///< Type of metadata item.
00133     const char *comment,               ///< Comment for metadata item.
00134     ...                                ///< Arguments for name formatting and metadata item data.
00135 )
00136 ;
00137 
00138 /** Checks the type of a particular pointer.
00139  *
00140  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00141  *
00142  *  @return bool:       True if the pointer matches a psMetadataItem structure, false otherwise.
00143  */
00144 bool psMemCheckMetadataItem(
00145     psPtr ptr                          ///< the pointer whose type to check
00146 );
00147 
00148 
00149 /** Create a metadata item with specified string data.
00150  *
00151  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00152  *  struct.
00153  *
00154  * @return psMetadataItem* : Pointer metadata item.
00155  */
00156 psMetadataItem* psMetadataItemAllocStr(
00157     const char* name,                  ///< Name of metadata item.
00158     const char* comment,               ///< Comment for metadata item.
00159     const char* value                  ///< the value of the metadata item.
00160 );
00161 
00162 /** Create a metadata item with specified psF32 data.
00163  *
00164  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00165  *  struct.
00166  *
00167  * @return psMetadataItem* : Pointer metadata item.
00168  */
00169 psMetadataItem* psMetadataItemAllocF32(
00170     const char* name,                  ///< Name of metadata item.
00171     const char* comment,               ///< Comment for metadata item.
00172     psF32 value                        ///< the value of the metadata item.
00173 );
00174 
00175 /** Create a metadata item with specified psF64 data.
00176  *
00177  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00178  *  struct.
00179  *
00180  * @return psMetadataItem* : Pointer metadata item.
00181  */
00182 psMetadataItem* psMetadataItemAllocF64(
00183     const char* name,                  ///< Name of metadata item.
00184     const char* comment,               ///< Comment for metadata item.
00185     psF64 value                        ///< the value of the metadata item.
00186 );
00187 
00188 /** Create a metadata item with specified psS32 data.
00189  *
00190  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00191  *  struct.
00192  *
00193  * @return psMetadataItem* : Pointer metadata item.
00194  */
00195 psMetadataItem* psMetadataItemAllocS32(
00196     const char* name,                  ///< Name of metadata item.
00197     const char* comment,               ///< Comment for metadata item.
00198     psS32 value                        ///< the value of the metadata item.
00199 );
00200 
00201 /** Create a metadata item with specified psBool data.
00202  *
00203  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00204  *  struct.
00205  *
00206  * @return psMetadataItem* : Pointer metadata item.
00207  */
00208 psMetadataItem* psMetadataItemAllocBool(
00209     const char* name,                  ///< Name of metadata item.
00210     const char* comment,               ///< Comment for metadata item.
00211     bool value                         ///< the value of the metadata item.
00212 );
00213 
00214 /** Create a metadata item with specified psPtr data.
00215  *
00216  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00217  *  struct.
00218  *
00219  * @return psMetadataItem* : Pointer metadata item.
00220  */
00221 psMetadataItem* psMetadataItemAllocPtr(
00222     const char* name,                  ///< Name of metadata item.
00223     psDataType type,                   ///< Data type of metadata item.
00224     const char* comment,               ///< Comment for metadata item.
00225     psPtr value                        ///< the value of the metadata item.
00226 );
00227 
00228 #ifndef SWIG
00229 /** Create a metadata item with va_list.
00230  *
00231  *  Returns a fill psMetadataItem ready for insertion into the psMetadata
00232  *  struct. The name argument specifies the name to use for this item, and
00233  *  may include sprintf formatting codes. The format entry specifies both
00234  *  the metadata type and optional flags and is created by bit-wise or of the
00235  *  appropriate type and flag. The comment argument is a fixed string used to
00236  *  comment the metadata item. The arguments to the name formatting codes and
00237  *  the metadata itself are passed as arguments following the comment string.
00238  *  The data must be a pointer for any of the elements stored in data.void.
00239  *  The argument list must be interpreted appropriately by the va_list
00240  *  operators in the function specified size and type.
00241  *
00242  * @return psMetadataItem* : Pointer metadata item.
00243  */
00244 psMetadataItem* psMetadataItemAllocV(
00245     const char *name,                  ///< Name of metadata item.
00246     psDataType type,                   ///< Type of metadata item.
00247     const char *comment,               ///< Comment for metadata item.
00248     va_list list                       ///< Arguments for name formatting and metadata item data.
00249 );
00250 #endif // #ifndef SWIG
00251 
00252 /** Create a metadata collection.
00253  *
00254  *  Returns an empty metadata container with fully allocated internal metadata
00255  *  containers.
00256  *
00257  *  @return psMetadata* : Pointer metadata.
00258  */
00259 psMetadata* psMetadataAlloc(void);
00260 
00261 
00262 /** Checks the type of a particular pointer.
00263  *
00264  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00265  *
00266  *  @return bool:       True if the pointer matches a psMetadata structure, false otherwise.
00267  */
00268 bool psMemCheckMetadata(
00269     psPtr ptr                          ///< the pointer whose type to check
00270 );
00271 
00272 
00273 /** Add existing metadata item to metadata collection.
00274  *
00275  *  Add a metadata item that has already been created to the metadata
00276  *  collection.
00277  *
00278  *  @return bool: True for success, false for failure.
00279  */
00280 bool psMetadataAddItem(
00281     psMetadata*  md,                   ///< Metadata collection to insert metadat item.
00282     const psMetadataItem* item,        ///< Metadata item to be added.
00283     int location,                      ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00284     psS32 flags                        ///< Options flag mask, see psMetadataFlags enum
00285 );
00286 
00287 /** Create and add a metadata item to metadata collection.
00288  *
00289  * Creates a new metadata item add to the metadata collection.
00290  *
00291  * @return bool: True for success, false for failure.
00292  */
00293 bool psMetadataAdd(
00294     psMetadata* md,                    ///< Metadata collection to insert metadata item.
00295     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00296     const char *name,                  ///< Name of metadata item.
00297     int format,                        ///< Type of metadata item (psMetadataType) and options (psMetadataFlags)
00298     const char *comment,               ///< Comment for metadata item.
00299     ...                                ///< Arguments for name formatting and metadata item data.
00300 );
00301 
00302 #ifndef SWIG
00303 /** Create and add a metadata item to metadata collection.
00304  *
00305  * Creates a new metadata item add to the metadata collection.
00306  *
00307  * @return bool: True for success, false for failure.
00308  */
00309 bool psMetadataAddV(
00310     psMetadata* md,                    ///< Metadata collection to insert metadata item.
00311     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00312     const char *name,                  ///< Name of metadata item.
00313     int format,                        ///< Type of metadata item (psMetadataType) and options (psMetadataFlags)
00314     const char *comment,               ///< Comment for metadata item.
00315     va_list list                       ///< Arguments for name formatting and metadata item data.
00316 );
00317 #endif // #ifndef SWIG
00318 
00319 /** Add a psBool value to metadata collection.
00320  *
00321  *  @return bool:  True for success, False for failure.
00322  */
00323 bool psMetadataAddBool(
00324     psMetadata* md,                    ///< Metadata collection to insert metadata item
00325     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00326     const char* name,                  ///< Name of metadata item
00327     int format,                        ///< psMetadataFlag options/flags
00328     const char* comment,               ///< Comment for metadata item
00329     bool value                       ///< Value for metadata item data
00330 );
00331 
00332 /** Add a psS32 value to metadata collection.
00333  *
00334  *  @return bool:  True for success, False for failure.
00335  */
00336 bool psMetadataAddS32(
00337     psMetadata* md,                    ///< Metadata collection to insert metadata item
00338     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00339     const char* name,                  ///< Name of metadata item
00340     int format,                        ///< psMetadataFlag options/flags
00341     const char* comment,               ///< Comment for metadata item
00342     psS32 value                        ///< Value for metadata item data
00343 );
00344 
00345 /** Add a psF32 value to metadata collection.
00346  *
00347  *  @return bool:  True for success, False for failure.
00348 */
00349 bool psMetadataAddF32(
00350     psMetadata* md,                    ///< Metadata collection to insert metadata item
00351     long location,                    ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00352     const char* name,                  ///< Name of metadata item
00353     int format,                        ///< psMetadataFlag options/flags
00354     const char* comment,               ///< Comment for metadata item
00355     psF32 value                        ///< Value for metadata item data
00356 );
00357 
00358 /** Add a psF64 value to metadata collection.
00359  *
00360  *  @return bool:  True for success, False for failure.
00361 */
00362 bool psMetadataAddF64(
00363     psMetadata* md,                    ///< Metadata collection to insert metadata item
00364     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00365     const char* name,                  ///< Name of metadata item
00366     int format,                        ///< psMetadataFlag options/flags
00367     const char* comment,               ///< Comment for metadata item
00368     psF64 value                        ///< Value for metadata item data
00369 );
00370 
00371 /** Add a psList to metadata collection.
00372  *
00373  *  @return psBool:  True for success, False for failure.
00374  */
00375 psBool psMetadataAddList(
00376     psMetadata* md,                    ///< Metadata collection to insert metadata item
00377     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00378     const char* name,                  ///< Name of metadata item
00379     int format,                        ///< psMetadataFlag options/flags
00380     const char* comment,               ///< Comment for metadata item
00381     psList* value                      ///< psList for metadata item data
00382 );
00383 
00384 /** Add a string to metadata collection.
00385  *
00386  *  @return bool:  True for success, False for failure.
00387  */
00388 bool psMetadataAddStr(
00389     psMetadata* md,                    ///< Metadata collection to insert metadata item
00390     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00391     const char* name,                  ///< Name of metadata item
00392     int format,                        ///< psMetadataFlag options/flags
00393     const char* comment,               ///< Comment for metadata item
00394     const char* value                  ///< String for metadata item data
00395 );
00396 
00397 /** Add a vector to metadata collection.
00398  *
00399  *  @return psBool:  True for success, False for failure.
00400  */
00401 psBool psMetadataAddVector(
00402     psMetadata* md,                    ///< Metadata collection to insert metadata item
00403     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00404     const char* name,                  ///< Name of metadata item
00405     int format,                        ///< psMetadataFlag options/flags
00406     const char* comment,               ///< Comment for metadata item
00407     psVector* value                    ///< Vector for metadata item data
00408 );
00409 
00410 /** Add a array to metadata collection.
00411  *
00412  *  @return psBool:  True for success, False for failure.
00413  */
00414 psBool psMetadataAddArray(
00415     psMetadata* md,                    ///< Metadata collection to insert metadata item
00416     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00417     const char* name,                  ///< Name of metadata item
00418     int format,                        ///< psMetadataFlag options/flags
00419     const char* comment,               ///< Comment for metadata item
00420     psArray* value                     ///< Vector for metadata item data
00421 );
00422 
00423 /** Add an Image to metadata collection.
00424  *
00425  *  @return psBool:  True for success, False for failure.
00426  */
00427 psBool psMetadataAddImage(
00428     psMetadata* md,                    ///< Metadata collection to insert metadata item
00429     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00430     const char* name,                  ///< Name of metadata item
00431     int format,                        ///< psMetadataFlag options/flags
00432     const char* comment,               ///< Comment for metadata item
00433     psImage* value                     ///< Image for metadata item data
00434 );
00435 
00436 /** Add a Time to metadata collection.
00437  *
00438  *  @return psBool:  True for success, False for failure.
00439  */
00440 psBool psMetadataAddTime(
00441     psMetadata* md,                    ///< Metadata collection to insert metadata item
00442     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00443     const char* name,                  ///< Name of metadata item
00444     int format,                        ///< psMetadataFlag options/flags
00445     const char* comment,               ///< Comment for metadata item
00446     psTime* value                      ///< Time for metadata item data
00447 );
00448 
00449 /** Add a Hash to metadata collection.
00450  *
00451  *  @return psBool:  True for success, False for failure.
00452  */
00453 psBool psMetadataAddHash(
00454     psMetadata* md,                    ///< Metadata collection to insert metadata item
00455     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00456     const char* name,                  ///< Name of metadata item
00457     int format,                        ///< psMetadataFlag options/flags
00458     const char* comment,               ///< Comment for metadata item
00459     psHash* value                      ///< Hash for metadata item data
00460 );
00461 
00462 /** Add a LookupTable to metadata collection.
00463  *
00464  *  @return psBool:  True for success, False for failure.
00465  */
00466 psBool psMetadataAddLookupTable(
00467     psMetadata* md,                    ///< Metadata collection to insert metadata item
00468     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00469     const char* name,                  ///< Name of metadata item
00470     int format,                        ///< psMetadataFlag options/flags
00471     const char* comment,               ///< Comment for metadata item
00472     psLookupTable* value               ///< LookupTable for metadata item data
00473 );
00474 
00475 /** Add an Unknown (psPtr) to metadata collection.
00476  *
00477  *  @return psBool:  True for success, False for failure.
00478  */
00479 psBool psMetadataAddUnknown(
00480     psMetadata* md,                    ///< Metadata collection to insert metadata item
00481     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00482     const char* name,                  ///< Name of metadata item
00483     int format,                        ///< psMetadataFlag options/flags
00484     const char* comment,               ///< Comment for metadata item
00485     psPtr value                        ///< Unknown for metadata item data
00486 );
00487 
00488 /** Add a psPtr to metadata collection.
00489  *
00490  *  @return bool:  True for success, False for failure.
00491  */
00492 psBool psMetadataAddPtr(
00493     psMetadata* md,                    ///< Metadata collection to insert metadata item
00494     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00495     const char* name,                  ///< Name of metadata item
00496     psDataType type,                   ///< psDataType for metadata item
00497     const char* comment,               ///< Comment for metadata item
00498     psPtr value                        ///< Unknown for metadata item data
00499 );
00500 
00501 /** Add Metadata to metadata collection.
00502  *
00503  *  @return psBool:  True for success, False for failure.
00504  */
00505 psBool psMetadataAddMetadata(
00506     psMetadata* md,                    ///< Metadata collection to insert metadata item
00507     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00508     const char* name,                  ///< Name of metadata item
00509     int format,                        ///< psMetadataFlag options/flags
00510     const char* comment,               ///< Comment for metadata item
00511     psMetadata* value                  ///< Metadata for metadata item data
00512 );
00513 
00514 /** Remove an item from metadata collection.
00515  *
00516  *  Items may be removed from metadata by specifing a key or location. If the
00517  *  name is null, the where argument is used instead. If name is not null,
00518  *  where is set to PS_LIST_UNKNOWN. If the item is found, it is removed from
00519  *  the metadata and true is returned.  If the key is not unique, then all
00520  *  items corresponding to it are removed.
00521  *
00522  * @return bool: True for success, false for failure.
00523  */
00524 bool psMetadataRemove(
00525     psMetadata*  md,                   ///< Metadata collection to remove metadata item.
00526     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00527     const char * key                   ///< Name of metadata key.
00528 );
00529 
00530 /** Removes an item from metadata by key name.
00531  *
00532  *  @return bool:  True for success, false for failure.
00533  */
00534 bool psMetadataRemoveKey(
00535     psMetadata *md,                    ///< Metadata collection to remove metadata item.
00536     const char *key                    ///< Name of metadata key.
00537 );
00538 
00539 /** Removes an item from metadata by index number.
00540  *
00541  *  @return bool:  True for success, false for failure.
00542  */
00543 bool psMetadataRemoveIndex(
00544     psMetadata *md,                    ///< Metadata collection to remove metadata item.
00545     int location                       ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00546 );
00547 
00548 
00549 /** Find an item in the metadata collection based on key name.
00550  *
00551  *  Items may be found in the metadata by providing a key. If the key is
00552  *  non-unique, the first item is returned. If the item is not found, null is
00553  *  returned.
00554  *
00555  * @return psMetadataItem* : Pointer metadata item.
00556  */
00557 psMetadataItem* psMetadataLookup(
00558     const psMetadata * md,             ///< Metadata collection to lookup metadata item.
00559     const char * key                   ///< Name of metadata key.
00560 );
00561 
00562 /** Find an item in the metadata collection based on key name and return its double precision value.
00563  *
00564  *  Items may be found in the metadata by providing a key. If the key is
00565  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00566  *  returned.
00567  *
00568  * @return psF64 : Value of metadata item.
00569  */
00570 psF64 psMetadataLookupF64(
00571     bool *status,                      ///< Status of lookup.
00572     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00573     const char *key                    ///< Name of metadata key.
00574 );
00575 
00576 /** Find an item in the metadata collection based on key name and return its single precision value.
00577  *
00578  *  Items may be found in the metadata by providing a key. If the key is
00579  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00580  *  returned.
00581  *
00582  * @return psF32 : Value of metadata item.
00583  */
00584 psF32 psMetadataLookupF32(
00585     bool *status,                      ///< Status of lookup.
00586     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00587     const char *key                    ///< Name of metadata key.
00588 );
00589 
00590 /** Find an item in the metadata collection based on key name and return its integer value.
00591  *
00592  *  Items may be found in the metadata by providing a key. If the key is
00593  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00594  *  returned.
00595  *
00596  * @return psS32 : Value of metadata item.
00597  */
00598 psS32 psMetadataLookupS32(
00599     bool *status,                      ///< Status of lookup.
00600     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00601     const char *key                    ///< Name of metadata key.
00602 );
00603 
00604 /** Find an item in the metadata collection based on key name and return its boolean value.
00605  *
00606  *  Items may be found in the metadata by providing a key. If the key is
00607  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00608  *  returned.
00609  *
00610  * @return bool : Value of metadata item.
00611  */
00612 bool psMetadataLookupBool(
00613     bool *status,                      ///< Status of lookup.
00614     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00615     const char *key                    ///< Name of metadata key.
00616 );
00617 
00618 /** Find an item in the metadata collection based on key name and return its integer value.
00619  *
00620  *  Items may be found in the metadata by providing a key. If the key is
00621  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00622  *  returned.
00623  *
00624  * @return void* : Value of metadata item.
00625  */
00626 psPtr psMetadataLookupPtr(
00627     bool *status,                      ///< Status of lookup.
00628     const psMetadata* md,              ///< Metadata collection to lookup metadata item.
00629     const char *key                    ///< Name of metadata key.
00630 );
00631 
00632 /** Find an item in the metadata collection based on list index.
00633  *
00634  *  Items may be found in the metadata by their entry position in the list
00635  *  container.
00636  *
00637  *  @return psMetadataItem* : Pointer metadata item.
00638  */
00639 psMetadataItem* psMetadataGet(
00640     const psMetadata* md,              ///< Metadata collection to retrieve metadata item.
00641     int location                       ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00642 );
00643 
00644 /** Creates a psMetadataIterator to iterate over the specified psMetadata.
00645  *
00646  *  Supports the subsetting of the metadata via keyword using regular
00647  *  expression.  If no regular expression is specified, iteration
00648  *  over the entire psMetadata is performed.
00649  *
00650  *  @return psMetadataIterator*        a new psMetadataIterator, of NULL if error occurred
00651  */
00652 psMetadataIterator* psMetadataIteratorAlloc(
00653     psMetadata* md,                    ///< the psMetadata to iterate with
00654     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00655     const char* regex
00656     ///< A regular expression for subsetting the psMetadata.  If NULL, no
00657     ///< subsetting is performed.
00658 );
00659 
00660 /** Set the iterator of the psMetadat to a given position.  If location is
00661  *  invalid the iterator position is not changed.
00662  *
00663  *  @return bool        TRUE if iterator successfully set, otherwise FALSE.
00664 */
00665 bool psMetadataIteratorSet(
00666     psMetadataIterator* iterator,      ///< psMetadata iterator
00667     long location                      ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
00668 );
00669 
00670 /** Position the specified iterator to the next matching item in psMetadata,
00671  *  given the regular expression of the iterator
00672  *
00673  *  @return psPtr       the psMetadataItem at the original iterator position
00674  *                      or NULL if the iterator went past the end of the list.
00675  */
00676 psMetadataItem* psMetadataGetAndIncrement(
00677     psMetadataIterator* iterator       ///< iterator to move
00678 );
00679 
00680 /** Position the specified iterator to the previous matching item in psMetadata,
00681  *  given the regular expression of the iterator
00682  *
00683  *  @return psPtr       the psMetadataItem at the original iterator position
00684  *                      or NULL if the iterator went past the beginning of the
00685  *                      list.
00686  */
00687 psMetadataItem* psMetadataGetAndDecrement(
00688     psMetadataIterator* iterator       ///< iterator to move
00689 );
00690 
00691 /** Find an item in the metadata collection based on key name and return its metadata value.
00692  *
00693  *  Items may be found in the metadata by providing a key. If the key is
00694  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00695  *  returned.
00696  *
00697  *  @return psMetadata*:        Value of metadata item.
00698  */
00699 psMetadata *psMetadataLookupMD(
00700     bool *status,                      ///< Status of lookup.
00701     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00702     const char *key                    ///< Name of metadata key.
00703 );
00704 
00705 /** Find an item in the metadata collection based on key name and return its string value.
00706  *
00707  *  Items may be found in the metadata by providing a key. If the key is
00708  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00709  *  returned.
00710  *
00711  *  @return char*:           Value of metadata item.
00712  */
00713 char *psMetadataLookupStr(
00714     bool *status,                      ///< Status of lookup.
00715     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00716     const char *key                    ///< Name of metadata key.
00717 );
00718 
00719 /** Print metadata collection to screen      */
00720 void psMetadataPrint(
00721     psMetadata *md,                    ///< Metadata collection to print.
00722     int level                          ///< the level of metadata items.
00723 );
00724 
00725 /** Implements the various verbosity controls.
00726  *
00727  *  Arguments shall be removed from the argument list as they are processed.
00728  *
00729  *  @return int:        The resultant logging level.
00730  */
00731 int psArgumentVerbosity(
00732     int *argc,                         ///< number or arguments
00733     char **argv                        ///< the argument list
00734 );
00735 
00736 /** Checks for an argument and returns its index position if found.
00737  *
00738  *  @return int:        The index of the element in the argument list, otherwise 0.
00739  */
00740 int psArgumentGet(
00741     int argc,                          ///< number or arguments
00742     char **argv,                       ///< the argument list
00743     const char *arg                    ///< the specified argument to match
00744 );
00745 
00746 /** Removes from the argument list the argument whose index is argnum.
00747  *
00748  *  The number of entries in the argument list shall be decremented.
00749  *
00750  *  @return bool:       True if the argnum is in the argument list, otherwise false.
00751  */
00752 bool psArgumentRemove(
00753     int argnum,                        ///< the argument to remove
00754     int *argc,                         ///< number or arguments
00755     char **argv                        ///< the argument list
00756 );
00757 
00758 /** Parses the command line arguments into a metadata container of arguments.
00759  *
00760  *  The input arguments shall contain the list of possible arguments as the keywords providing
00761  *  the default values.  As matching arguments are found on the command line, the values shall be
00762  *  read into the arguments metadata, with the appropriate type.  The arguments and their values
00763  *  shall be removed from the list of command line arguments as they are processed.
00764  *
00765  *  @return bool:       False if any argument was encountered that is not present in arguments.
00766  */
00767 bool psArgumentParse(
00768     psMetadata *arguments,             ///< metadata container for arguments
00769     int *argc,                         ///< number or arguments
00770     char **argv                        ///< the argument list
00771 );
00772 
00773 /** Prints to stdout a guide to the command-line arguments.      */
00774 void psArgumentHelp(
00775     psMetadata *arguments              ///< metadata container for arguments
00776 );
00777 
00778 /// @}
00779 
00780 #endif // #ifndef PS_METADATA_H

Generated on Thu Oct 13 14:32:52 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2