#include <stdlib.h>
#include "nmd.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Test GetOrCreate components
Definition at line 5 of file u5.c.
References NMDCategoryAllocateNewComponent(), NMDCategoryGetOrCreateComponent(), NMDCreateObject(), NMDDestroyObject(), NMDInt, NMDObjectAllocateNewCategory(), NMDReal, and NMDString.
00005 { 00006 NMD_metadata nmd; NMDErrorCode ierr; 00007 PetscFunctionBegin; 00008 PetscInitialize(&argc,&argv,0,0); 00009 ierr = NMDCreateObject(&nmd); NMD_ERR_RETURN(ierr); 00010 00011 { 00012 NMD_metadata_category cat; NMD_metadata_item cmp; 00013 00014 ierr = NMDObjectAllocateNewCategory 00015 (nmd,"cat2",&cat); NMD_ERR_RETURN(ierr); 00016 00017 ierr = NMDCategoryAllocateNewComponent 00018 (cat,"p1",NMDInt,NULL); NMD_ERR_RETURN(ierr); 00019 ierr = NMDCategoryAllocateNewComponent 00020 (cat,"ptwo",NMDReal,NULL); NMD_ERR_RETURN(ierr); 00021 00022 /* this call will make the program abort 00023 because of the type mismatch */ 00024 printf("Type mismatch error coming up:\n\n"); 00025 ierr = NMDCategoryGetOrCreateComponent 00026 (cat,"p1",NMDString,NULL); NMD_ERR_RETURN(ierr); 00027 ierr = NMDCategoryGetOrCreateComponent 00028 (cat,"ptwo",NMDReal,&cmp); NMD_ERR_RETURN(ierr); 00029 00030 } 00031 00032 ierr = NMDDestroyObject(nmd); NMD_ERR_RETURN(ierr); 00033 PetscFinalize(); 00034 PetscFunctionReturn(0); 00035 }