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.71 $ $Name: rel9_0 $
00014 *  @date $Date: 2005/11/18 01:51:03 $
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 /** Creates a new copy of all the psMetadataItems in the psMetadata collection, in, and
00273  *  returns them in out, or creates a new container if out is NULL.
00274  *
00275  *  @return psMetadata*:        the copy of the psMetadata container.
00276  */
00277 psMetadata *psMetadataCopy(
00278     psMetadata *out,                   ///< output Metadata container for copying.
00279     const psMetadata *in               ///< Metadata collection to be copied.
00280 );
00281 
00282 /** Add existing metadata item to metadata collection.
00283  *
00284  *  Add a metadata item that has already been created to the metadata
00285  *  collection.
00286  *
00287  *  @return bool: True for success, false for failure.
00288  */
00289 bool psMetadataAddItem(
00290     psMetadata*  md,                   ///< Metadata collection to insert metadata item.
00291     const psMetadataItem* item,        ///< Metadata item to be added.
00292     int location,                      ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00293     psS32 flags                        ///< Options flag mask, see psMetadataFlags enum
00294 );
00295 
00296 /** Create and add a metadata item to metadata collection.
00297  *
00298  * Creates a new metadata item add to the metadata collection.
00299  *
00300  * @return bool: True for success, false for failure.
00301  */
00302 bool psMetadataAdd(
00303     psMetadata* md,                    ///< Metadata collection to insert metadata item.
00304     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00305     const char *name,                  ///< Name of metadata item.
00306     int format,                        ///< Type of metadata item (psMetadataType) and options (psMetadataFlags)
00307     const char *comment,               ///< Comment for metadata item.
00308     ...                                ///< Arguments for name formatting and metadata item data.
00309 );
00310 
00311 #ifndef SWIG
00312 /** Create and add a metadata item to metadata collection.
00313  *
00314  * Creates a new metadata item add to the metadata collection.
00315  *
00316  * @return bool: True for success, false for failure.
00317  */
00318 bool psMetadataAddV(
00319     psMetadata* md,                    ///< Metadata collection to insert metadata item.
00320     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00321     const char *name,                  ///< Name of metadata item.
00322     int format,                        ///< Type of metadata item (psMetadataType) and options (psMetadataFlags)
00323     const char *comment,               ///< Comment for metadata item.
00324     va_list list                       ///< Arguments for name formatting and metadata item data.
00325 );
00326 #endif // #ifndef SWIG
00327 
00328 /** Add a psBool value to metadata collection.
00329  *
00330  *  @return bool:  True for success, False for failure.
00331  */
00332 bool psMetadataAddBool(
00333     psMetadata* md,                    ///< Metadata collection to insert metadata item
00334     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00335     const char* name,                  ///< Name of metadata item
00336     int format,                        ///< psMetadataFlag options/flags
00337     const char* comment,               ///< Comment for metadata item
00338     bool value                       ///< Value for metadata item data
00339 );
00340 
00341 /** Add a psS32 value to metadata collection.
00342  *
00343  *  @return bool:  True for success, False for failure.
00344  */
00345 bool psMetadataAddS32(
00346     psMetadata* md,                    ///< Metadata collection to insert metadata item
00347     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00348     const char* name,                  ///< Name of metadata item
00349     int format,                        ///< psMetadataFlag options/flags
00350     const char* comment,               ///< Comment for metadata item
00351     psS32 value                        ///< Value for metadata item data
00352 );
00353 
00354 /** Add a psF32 value to metadata collection.
00355  *
00356  *  @return bool:  True for success, False for failure.
00357 */
00358 bool psMetadataAddF32(
00359     psMetadata* md,                    ///< Metadata collection to insert metadata item
00360     long location,                    ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00361     const char* name,                  ///< Name of metadata item
00362     int format,                        ///< psMetadataFlag options/flags
00363     const char* comment,               ///< Comment for metadata item
00364     psF32 value                        ///< Value for metadata item data
00365 );
00366 
00367 /** Add a psF64 value to metadata collection.
00368  *
00369  *  @return bool:  True for success, False for failure.
00370 */
00371 bool psMetadataAddF64(
00372     psMetadata* md,                    ///< Metadata collection to insert metadata item
00373     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00374     const char* name,                  ///< Name of metadata item
00375     int format,                        ///< psMetadataFlag options/flags
00376     const char* comment,               ///< Comment for metadata item
00377     psF64 value                        ///< Value for metadata item data
00378 );
00379 
00380 /** Add a psList to metadata collection.
00381  *
00382  *  @return psBool:  True for success, False for failure.
00383  */
00384 psBool psMetadataAddList(
00385     psMetadata* md,                    ///< Metadata collection to insert metadata item
00386     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00387     const char* name,                  ///< Name of metadata item
00388     int format,                        ///< psMetadataFlag options/flags
00389     const char* comment,               ///< Comment for metadata item
00390     psList* value                      ///< psList for metadata item data
00391 );
00392 
00393 /** Add a string to metadata collection.
00394  *
00395  *  @return bool:  True for success, False for failure.
00396  */
00397 bool psMetadataAddStr(
00398     psMetadata* md,                    ///< Metadata collection to insert metadata item
00399     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00400     const char* name,                  ///< Name of metadata item
00401     int format,                        ///< psMetadataFlag options/flags
00402     const char* comment,               ///< Comment for metadata item
00403     const char* value                  ///< String for metadata item data
00404 );
00405 
00406 /** Add a vector to metadata collection.
00407  *
00408  *  @return psBool:  True for success, False for failure.
00409  */
00410 psBool psMetadataAddVector(
00411     psMetadata* md,                    ///< Metadata collection to insert metadata item
00412     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00413     const char* name,                  ///< Name of metadata item
00414     int format,                        ///< psMetadataFlag options/flags
00415     const char* comment,               ///< Comment for metadata item
00416     psVector* value                    ///< Vector for metadata item data
00417 );
00418 
00419 /** Add a array to metadata collection.
00420  *
00421  *  @return psBool:  True for success, False for failure.
00422  */
00423 psBool psMetadataAddArray(
00424     psMetadata* md,                    ///< Metadata collection to insert metadata item
00425     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00426     const char* name,                  ///< Name of metadata item
00427     int format,                        ///< psMetadataFlag options/flags
00428     const char* comment,               ///< Comment for metadata item
00429     psArray* value                     ///< Vector for metadata item data
00430 );
00431 
00432 /** Add an Image to metadata collection.
00433  *
00434  *  @return psBool:  True for success, False for failure.
00435  */
00436 psBool psMetadataAddImage(
00437     psMetadata* md,                    ///< Metadata collection to insert metadata item
00438     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00439     const char* name,                  ///< Name of metadata item
00440     int format,                        ///< psMetadataFlag options/flags
00441     const char* comment,               ///< Comment for metadata item
00442     psImage* value                     ///< Image for metadata item data
00443 );
00444 
00445 /** Add a Time to metadata collection.
00446  *
00447  *  @return psBool:  True for success, False for failure.
00448  */
00449 psBool psMetadataAddTime(
00450     psMetadata* md,                    ///< Metadata collection to insert metadata item
00451     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00452     const char* name,                  ///< Name of metadata item
00453     int format,                        ///< psMetadataFlag options/flags
00454     const char* comment,               ///< Comment for metadata item
00455     psTime* value                      ///< Time for metadata item data
00456 );
00457 
00458 /** Add a Hash to metadata collection.
00459  *
00460  *  @return psBool:  True for success, False for failure.
00461  */
00462 psBool psMetadataAddHash(
00463     psMetadata* md,                    ///< Metadata collection to insert metadata item
00464     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00465     const char* name,                  ///< Name of metadata item
00466     int format,                        ///< psMetadataFlag options/flags
00467     const char* comment,               ///< Comment for metadata item
00468     psHash* value                      ///< Hash for metadata item data
00469 );
00470 
00471 /** Add a LookupTable to metadata collection.
00472  *
00473  *  @return psBool:  True for success, False for failure.
00474  */
00475 psBool psMetadataAddLookupTable(
00476     psMetadata* md,                    ///< Metadata collection to insert metadata item
00477     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00478     const char* name,                  ///< Name of metadata item
00479     int format,                        ///< psMetadataFlag options/flags
00480     const char* comment,               ///< Comment for metadata item
00481     psLookupTable* value               ///< LookupTable for metadata item data
00482 );
00483 
00484 /** Add an Unknown (psPtr) to metadata collection.
00485  *
00486  *  @return psBool:  True for success, False for failure.
00487  */
00488 psBool psMetadataAddUnknown(
00489     psMetadata* md,                    ///< Metadata collection to insert metadata item
00490     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00491     const char* name,                  ///< Name of metadata item
00492     int format,                        ///< psMetadataFlag options/flags
00493     const char* comment,               ///< Comment for metadata item
00494     psPtr value                        ///< Unknown for metadata item data
00495 );
00496 
00497 /** Add a psPtr to metadata collection.
00498  *
00499  *  @return bool:  True for success, False for failure.
00500  */
00501 bool psMetadataAddPtr(
00502     psMetadata* md,                    ///< Metadata collection to insert metadata item
00503     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00504     const char* name,                  ///< Name of metadata item
00505     psDataType type,                   ///< psDataType for metadata item
00506     const char* comment,               ///< Comment for metadata item
00507     psPtr value                        ///< Unknown for metadata item data
00508 );
00509 
00510 /** Add Metadata to metadata collection.
00511  *
00512  *  @return psBool:  True for success, False for failure.
00513  */
00514 psBool psMetadataAddMetadata(
00515     psMetadata* md,                    ///< Metadata collection to insert metadata item
00516     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00517     const char* name,                  ///< Name of metadata item
00518     int format,                        ///< psMetadataFlag options/flags
00519     const char* comment,               ///< Comment for metadata item
00520     psMetadata* value                  ///< Metadata for metadata item data
00521 );
00522 
00523 /** Remove an item from metadata collection.
00524  *
00525  *  Items may be removed from metadata by specifing a key or location. If the
00526  *  name is null, the where argument is used instead. If name is not null,
00527  *  where is set to PS_LIST_UNKNOWN. If the item is found, it is removed from
00528  *  the metadata and true is returned.  If the key is not unique, then all
00529  *  items corresponding to it are removed.
00530  *
00531  * @return bool: True for success, false for failure.
00532  */
00533 bool psMetadataRemove(
00534     psMetadata*  md,                   ///< Metadata collection to remove metadata item.
00535     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00536     const char * key                   ///< Name of metadata key.
00537 );
00538 
00539 /** Removes an item from metadata by key name.
00540  *
00541  *  @return bool:  True for success, false for failure.
00542  */
00543 bool psMetadataRemoveKey(
00544     psMetadata *md,                    ///< Metadata collection to remove metadata item.
00545     const char *key                    ///< Name of metadata key.
00546 );
00547 
00548 /** Removes an item from metadata by index number.
00549  *
00550  *  @return bool:  True for success, false for failure.
00551  */
00552 bool psMetadataRemoveIndex(
00553     psMetadata *md,                    ///< Metadata collection to remove metadata item.
00554     int location                       ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00555 );
00556 
00557 
00558 /** Find an item in the metadata collection based on key name.
00559  *
00560  *  Items may be found in the metadata by providing a key. If the key is
00561  *  non-unique, the first item is returned. If the item is not found, null is
00562  *  returned.
00563  *
00564  * @return psMetadataItem* : Pointer metadata item.
00565  */
00566 psMetadataItem* psMetadataLookup(
00567     const psMetadata * md,             ///< Metadata collection to lookup metadata item.
00568     const char * key                   ///< Name of metadata key.
00569 );
00570 
00571 /** Find an item in the metadata collection based on key name and return its double precision value.
00572  *
00573  *  Items may be found in the metadata by providing a key. If the key is
00574  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00575  *  returned.
00576  *
00577  * @return psF64 : Value of metadata item.
00578  */
00579 psF64 psMetadataLookupF64(
00580     bool *status,                      ///< Status of lookup.
00581     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00582     const char *key                    ///< Name of metadata key.
00583 );
00584 
00585 /** Find an item in the metadata collection based on key name and return its single precision value.
00586  *
00587  *  Items may be found in the metadata by providing a key. If the key is
00588  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00589  *  returned.
00590  *
00591  * @return psF32 : Value of metadata item.
00592  */
00593 psF32 psMetadataLookupF32(
00594     bool *status,                      ///< Status of lookup.
00595     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00596     const char *key                    ///< Name of metadata key.
00597 );
00598 
00599 /** Find an item in the metadata collection based on key name and return its integer value.
00600  *
00601  *  Items may be found in the metadata by providing a key. If the key is
00602  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00603  *  returned.
00604  *
00605  * @return psS32 : Value of metadata item.
00606  */
00607 psS32 psMetadataLookupS32(
00608     bool *status,                      ///< Status of lookup.
00609     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00610     const char *key                    ///< Name of metadata key.
00611 );
00612 
00613 /** Find an item in the metadata collection based on key name and return its boolean value.
00614  *
00615  *  Items may be found in the metadata by providing a key. If the key is
00616  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00617  *  returned.
00618  *
00619  * @return bool : Value of metadata item.
00620  */
00621 bool psMetadataLookupBool(
00622     bool *status,                      ///< Status of lookup.
00623     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00624     const char *key                    ///< Name of metadata key.
00625 );
00626 
00627 /** Find an item in the metadata collection based on key name and return its integer value.
00628  *
00629  *  Items may be found in the metadata by providing a key. If the key is
00630  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00631  *  returned.
00632  *
00633  * @return void* : Value of metadata item.
00634  */
00635 psPtr psMetadataLookupPtr(
00636     bool *status,                      ///< Status of lookup.
00637     const psMetadata* md,              ///< Metadata collection to lookup metadata item.
00638     const char *key                    ///< Name of metadata key.
00639 );
00640 
00641 /** Find an item in the metadata collection based on list index.
00642  *
00643  *  Items may be found in the metadata by their entry position in the list
00644  *  container.
00645  *
00646  *  @return psMetadataItem* : Pointer metadata item.
00647  */
00648 psMetadataItem* psMetadataGet(
00649     const psMetadata* md,              ///< Metadata collection to retrieve metadata item.
00650     int location                       ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00651 );
00652 
00653 /** Creates a psMetadataIterator to iterate over the specified psMetadata.
00654  *
00655  *  Supports the subsetting of the metadata via keyword using regular
00656  *  expression.  If no regular expression is specified, iteration
00657  *  over the entire psMetadata is performed.
00658  *
00659  *  @return psMetadataIterator*        a new psMetadataIterator, of NULL if error occurred
00660  */
00661 psMetadataIterator* psMetadataIteratorAlloc(
00662     psMetadata* md,                    ///< the psMetadata to iterate with
00663     long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
00664     const char* regex
00665     ///< A regular expression for subsetting the psMetadata.  If NULL, no
00666     ///< subsetting is performed.
00667 );
00668 
00669 /** Set the iterator of the psMetadat to a given position.  If location is
00670  *  invalid the iterator position is not changed.
00671  *
00672  *  @return bool        TRUE if iterator successfully set, otherwise FALSE.
00673 */
00674 bool psMetadataIteratorSet(
00675     psMetadataIterator* iterator,      ///< psMetadata iterator
00676     long location                      ///< index number, PS_LIST_HEAD, or PS_LIST_TAIL
00677 );
00678 
00679 /** Position the specified iterator to the next matching item in psMetadata,
00680  *  given the regular expression of the iterator
00681  *
00682  *  @return psPtr       the psMetadataItem at the original iterator position
00683  *                      or NULL if the iterator went past the end of the list.
00684  */
00685 psMetadataItem* psMetadataGetAndIncrement(
00686     psMetadataIterator* iterator       ///< iterator to move
00687 );
00688 
00689 /** Position the specified iterator to the previous matching item in psMetadata,
00690  *  given the regular expression of the iterator
00691  *
00692  *  @return psPtr       the psMetadataItem at the original iterator position
00693  *                      or NULL if the iterator went past the beginning of the
00694  *                      list.
00695  */
00696 psMetadataItem* psMetadataGetAndDecrement(
00697     psMetadataIterator* iterator       ///< iterator to move
00698 );
00699 
00700 /** Find an item in the metadata collection based on key name and return its metadata value.
00701  *
00702  *  Items may be found in the metadata by providing a key. If the key is
00703  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00704  *  returned.
00705  *
00706  *  @return psMetadata*:        Value of metadata item.
00707  */
00708 psMetadata *psMetadataLookupMD(
00709     bool *status,                      ///< Status of lookup.
00710     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00711     const char *key                    ///< Name of metadata key.
00712 );
00713 
00714 /** Find an item in the metadata collection based on key name and return its string value.
00715  *
00716  *  Items may be found in the metadata by providing a key. If the key is
00717  *  non-unique, the value of the first item is returned. If the item is not found, zero is
00718  *  returned.
00719  *
00720  *  @return psString:           Value of metadata item.
00721  */
00722 psString psMetadataLookupStr(
00723     bool *status,                      ///< Status of lookup.
00724     const psMetadata *md,              ///< Metadata collection to lookup metadata item.
00725     const char *key                    ///< Name of metadata key.
00726 );
00727 
00728 /** Print metadata collection to screen      */
00729 void psMetadataPrint(
00730     psMetadata *md,                    ///< Metadata collection to print.
00731     int level                          ///< the level of metadata items.
00732 );
00733 
00734 /** Implements the various verbosity controls.
00735  *
00736  *  Arguments shall be removed from the argument list as they are processed.
00737  *
00738  *  @return int:        The resultant logging level.
00739  */
00740 int psArgumentVerbosity(
00741     int *argc,                         ///< number or arguments
00742     char **argv                        ///< the argument list
00743 );
00744 
00745 /** Checks for an argument and returns its index position if found.
00746  *
00747  *  @return int:        The index of the element in the argument list, otherwise 0.
00748  */
00749 int psArgumentGet(
00750     int argc,                          ///< number or arguments
00751     char **argv,                       ///< the argument list
00752     const char *arg                    ///< the specified argument to match
00753 );
00754 
00755 /** Removes from the argument list the argument whose index is argnum.
00756  *
00757  *  The number of entries in the argument list shall be decremented.
00758  *
00759  *  @return bool:       True if the argnum is in the argument list, otherwise false.
00760  */
00761 bool psArgumentRemove(
00762     int argnum,                        ///< the argument to remove
00763     int *argc,                         ///< number or arguments
00764     char **argv                        ///< the argument list
00765 );
00766 
00767 /** Parses the command line arguments into a metadata container of arguments.
00768  *
00769  *  The input arguments shall contain the list of possible arguments as the keywords providing
00770  *  the default values.  As matching arguments are found on the command line, the values shall be
00771  *  read into the arguments metadata, with the appropriate type.  The arguments and their values
00772  *  shall be removed from the list of command line arguments as they are processed.
00773  *
00774  *  @return bool:       False if any argument was encountered that is not present in arguments.
00775  */
00776 bool psArgumentParse(
00777     psMetadata *arguments,             ///< metadata container for arguments
00778     int *argc,                         ///< number or arguments
00779     char **argv                        ///< the argument list
00780 );
00781 
00782 /** Prints to stdout a guide to the command-line arguments.      */
00783 void psArgumentHelp(
00784     psMetadata *arguments              ///< metadata container for arguments
00785 );
00786 
00787 /// @}
00788 
00789 #endif // #ifndef PS_METADATA_H

Generated on Tue Dec 6 17:18:42 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2