Changeset 12532
- Timestamp:
- Mar 21, 2007, 3:14:52 PM (19 years ago)
- Location:
- trunk/psLib
- Files:
-
- 1 added
- 5 edited
-
src/types/psMetadata.c (modified) (5 diffs)
-
src/types/psMetadata.h (modified) (3 diffs)
-
test/types (modified) (1 prop)
-
test/types/.cvsignore (modified) (1 diff)
-
test/types/Makefile.am (modified) (1 diff)
-
test/types/tap_psMetadataUpdate.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psMetadata.c
r12460 r12532 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.15 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2007-03- 16 01:46:56$14 * @version $Revision: 1.156 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2007-03-22 01:14:52 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 463 463 psMetadataItem *newItem = psMetadataItemCopy(inItem); // Copied item 464 464 if (!psMetadataAddItem(out, newItem, PS_LIST_TAIL, flag)) { 465 psError StackPrint(stderr, "Error copying %s (%s) in the metadata\n", inItem->name,466 inItem->comment);465 psError(PS_ERR_UNKNOWN, false, "Error copying %s (%s) in the metadata\n", 466 inItem->name, inItem->comment); 467 467 if (outAlloced) { 468 468 psFree(out); … … 483 483 484 484 return out; 485 } 486 487 // this function copies the input metadata to the output, raising an error 488 // if any entries in 'in' a) do not exist in 'out' or b) have a different type 489 bool p_psMetadataUpdate(const char *file, 490 unsigned int lineno, 491 const char *func, 492 psMetadata *out, 493 const psMetadata *in) 494 { 495 PS_ASSERT_METADATA_NON_NULL(in, NULL); 496 PS_ASSERT_METADATA_NON_NULL(out, NULL); 497 498 psMetadataIterator *iter = psMetadataIteratorAlloc(in, PS_LIST_HEAD, NULL); 499 psMetadataItem *inItem = NULL; 500 while ((inItem = psMetadataGetAndIncrement(iter))) { 501 // Need to look for MULTI, which won't be picked up using the iterator. 502 psMetadataItem *multiCheckItem = psMetadataLookup(in, inItem->name); 503 unsigned int flag = PS_META_REPLACE | PS_META_REQUIRE_ENTRY | PS_META_REQUIRE_TYPE; // Flag to indicate MULTI; otherwise, replace 504 if (multiCheckItem->type == PS_DATA_METADATA_MULTI) { 505 psTrace("psLib.types", 10, "MULTI: %s (%s)\n", inItem->name, inItem->comment); 506 flag = PS_META_DUPLICATE_OK | PS_META_REQUIRE_ENTRY | PS_META_REQUIRE_TYPE; 507 } 508 psTrace("psLib.types", 5, "Copying %s (%s)...\n", inItem->name, inItem->comment); 509 510 // Copy the item and add it on 511 psMetadataItem *newItem = psMetadataItemCopy(inItem); // Copied item 512 if (!psMetadataAddItem(out, newItem, PS_LIST_TAIL, flag)) { 513 psError(PS_ERR_UNKNOWN, false, "Error copying %s (%s) in the metadata\n", 514 inItem->name, inItem->comment); 515 psFree(newItem); 516 psFree(iter); 517 return false; 518 } 519 psFree(newItem); // Drop reference 520 } 521 psFree(iter); 522 return true; 485 523 } 486 524 … … 572 610 } else if ((flags & PS_META_REPLACE) != 0) { 573 611 // replace entry instead of creating a duplicate entry. 612 613 if ((flags & PS_META_REQUIRE_TYPE) && (existingEntry->type != item->type)) { 614 psError (PS_ERR_UNKNOWN, true, _("existing item does not match type for item requiring matching type")); 615 return false; 616 } 574 617 575 618 // remove the existing entry from metadata … … 601 644 } else { 602 645 // OK, this is a new item. 646 if (flags & PS_META_REQUIRE_ENTRY) { 647 psError (PS_ERR_UNKNOWN, true, _("no matching item found for item requiring existing entry")); 648 return false; 649 } 603 650 604 651 // Node doesn't exist - Add new metadata item to metadata collection's hash -
trunk/psLib/src/types/psMetadata.h
r12475 r12532 9 9 * @author Ross Harman, MHPCC 10 10 * 11 * @version $Revision: 1.10 0$ $Name: not supported by cvs2svn $12 * @date $Date: 2007-03- 17 02:38:53$11 * @version $Revision: 1.101 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-03-22 01:14:52 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 61 61 PS_META_NO_REPLACE = 0x2000000, ///< duplicate entry is silently skipped 62 62 PS_META_DUPLICATE_OK = 0x4000000, ///< allow duplicate entries 63 PS_META_NULL = 0x8000000 ///< psMetadataItem.data is a NULL value 63 PS_META_NULL = 0x8000000, ///< psMetadataItem.data is a NULL value 64 PS_META_REQUIRE_ENTRY = 0x10000000, ///< require pre-existing entry with same name 65 PS_META_REQUIRE_TYPE = 0x20000000 ///< require pre-existing entry to have same type 64 66 } psMetadataFlags; 65 67 … … 480 482 481 483 484 /** Updates an existing psMetadata collection with elements from a metadata collection 485 * 486 * Creates a new copy of all the psMetadataItems in the psMetadata collection 'in' and places 487 * them in out. all items in 'in' must already be in 'out' and be of the same type. 488 * 489 * @return psMetadata*: the copy of the psMetadata container. 490 */ 491 #ifdef DOXYGEN 492 bool psMetadataUpdate( 493 psMetadata *out, ///< output Metadata container for copying. 494 const psMetadata *in ///< Metadata collection to be copied. 495 ); 496 #else // ifdef DOXYGEN 497 bool p_psMetadataUpdate( 498 const char *file, ///< File of caller 499 unsigned int lineno, ///< Line number of caller 500 const char *func, ///< Function name of caller 501 psMetadata *out, ///< output Metadata container for copying. 502 const psMetadata *in ///< Metadata collection to be copied. 503 ); 504 #define psMetadataUpdate(out, in) \ 505 p_psMetadataUpdate(__FILE__, __LINE__, __func__, out, in) 506 #endif // ifdef DOXYGEN 507 508 482 509 /** Supplements a metadata with an item from another metadata. 483 510 * -
trunk/psLib/test/types
- Property svn:ignore
-
old new 72 72 tap_psMetadata_printing 73 73 tap_psPixels_all 74 tap_psMetadataUpdate
-
- Property svn:ignore
-
trunk/psLib/test/types/.cvsignore
r10821 r12532 74 74 tap_psMetadata_printing 75 75 tap_psPixels_all 76 77 tap_psMetadataUpdate -
trunk/psLib/test/types/Makefile.am
r12477 r12532 18 18 tap_psMetadataItemCompare \ 19 19 tap_psMetadataItemParse \ 20 tap_psMetadataUpdate \ 20 21 tap_psMetadata_printing \ 21 22 tap_psMetadata_copying \
Note:
See TracChangeset
for help on using the changeset viewer.
