Changeset 14008
- Timestamp:
- Jul 3, 2007, 3:36:14 PM (19 years ago)
- Location:
- trunk/psLib
- Files:
-
- 1 added
- 3 edited
-
src/types/psMetadata.c (modified) (2 diffs)
-
src/types/psMetadata.h (modified) (2 diffs)
-
test/types/Makefile.am (modified) (1 diff)
-
test/types/tap_psMetadataOverlay.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psMetadata.c
r13689 r14008 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.16 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2007-0 6-07 00:42:13$14 * @version $Revision: 1.162 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2007-07-04 01:36:14 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 509 509 } 510 510 psTrace("psLib.types", 5, "Copying %s (%s)...\n", inItem->name, inItem->comment); 511 512 // Copy the item and add it on. report all errors so we get a listing 513 psMetadataItem *newItem = psMetadataItemCopy(inItem); // Copied item 514 if (!psMetadataAddItem(out, newItem, PS_LIST_TAIL, flag)) { 515 fprintf (stderr, "Error copying %s\n", inItem->name); 516 result = false; 517 } 518 psFree(newItem); // Drop reference 519 } 520 psFree(iter); 521 522 if (!result) { 523 psError(PS_ERR_UNKNOWN, false, "failed to update metadata\n"); 524 } 525 return result; 526 } 527 528 // this function copies the input metadata to the output, supplementing existing metadata 529 // folders with the contents from corresponding folders in the output 530 bool p_psMetadataOverlay(const char *file, 531 unsigned int lineno, 532 const char *func, 533 psMetadata *out, 534 const psMetadata *in) 535 { 536 PS_ASSERT_METADATA_NON_NULL(in, NULL); 537 PS_ASSERT_METADATA_NON_NULL(out, NULL); 538 539 bool result = true; 540 541 psMetadataIterator *iter = psMetadataIteratorAlloc(in, PS_LIST_HEAD, NULL); 542 psMetadataItem *inItem = NULL; 543 while ((inItem = psMetadataGetAndIncrement(iter))) { 544 // Need to look for MULTI, which won't be picked up using the iterator. 545 psMetadataItem *multiCheckItem = psMetadataLookup(in, inItem->name); 546 unsigned int flag = PS_META_REPLACE; // Flag to indicate MULTI; otherwise, replace 547 if (multiCheckItem->type == PS_DATA_METADATA_MULTI) { 548 psTrace("psLib.types", 10, "MULTI: %s (%s)\n", inItem->name, inItem->comment); 549 flag = PS_META_DUPLICATE_OK; 550 } 551 psTrace("psLib.types", 5, "Copying %s (%s)...\n", inItem->name, inItem->comment); 552 553 // if this is a metadata, and it has a corresponding match, overlay them 554 if (inItem->type == PS_DATA_METADATA) { 555 bool status; 556 psMetadata *outFolder = psMetadataLookupMetadata (&status, out, inItem->name); 557 if (outFolder) { 558 if (!psMetadataOverlay (outFolder, inItem->data.md)) { 559 fprintf (stderr, "Error overlaying metadata folder\n"); 560 result = false; 561 } 562 continue; 563 } 564 } 511 565 512 566 // Copy the item and add it on. report all errors so we get a listing -
trunk/psLib/src/types/psMetadata.h
r12532 r14008 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.10 1$ $Name: not supported by cvs2svn $12 * @date $Date: 2007-0 3-22 01:14:52$11 * @version $Revision: 1.102 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-07-04 01:36:14 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 507 507 508 508 509 /** Overlays an existing psMetadata collection with elements from a metadata collection 510 * 511 * Creates a new copy of all the psMetadataItems in the psMetadata collection 'in' and places 512 * them in out. matching metadata structures in 'out' are supplemented with corresponding 513 * entries from 'in' 514 * 515 * @return psMetadata*: the copy of the psMetadata container. 516 */ 517 #ifdef DOXYGEN 518 bool psMetadataOverlay( 519 psMetadata *out, ///< output Metadata container for copying. 520 const psMetadata *in ///< Metadata collection to be copied. 521 ); 522 #else // ifdef DOXYGEN 523 bool p_psMetadataOverlay( 524 const char *file, ///< File of caller 525 unsigned int lineno, ///< Line number of caller 526 const char *func, ///< Function name of caller 527 psMetadata *out, ///< output Metadata container for copying. 528 const psMetadata *in ///< Metadata collection to be copied. 529 ); 530 #define psMetadataOverlay(out, in) \ 531 p_psMetadataOverlay(__FILE__, __LINE__, __func__, out, in) 532 #endif // ifdef DOXYGEN 533 534 509 535 /** Supplements a metadata with an item from another metadata. 510 536 * -
trunk/psLib/test/types/Makefile.am
r12532 r14008 19 19 tap_psMetadataItemParse \ 20 20 tap_psMetadataUpdate \ 21 tap_psMetadataOverlay \ 21 22 tap_psMetadata_printing \ 22 23 tap_psMetadata_copying \
Note:
See TracChangeset
for help on using the changeset viewer.
