NMD
Functions
u5.c File Reference
#include <stdlib.h>
#include "nmd.h"
Include dependency graph for u5.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

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.

                               {
  NMD_metadata nmd; NMDErrorCode ierr;
  PetscFunctionBegin;
  PetscInitialize(&argc,&argv,0,0);
  ierr = NMDCreateObject(&nmd); NMD_ERR_RETURN(ierr);

  {
    NMD_metadata_category cat; NMD_metadata_item cmp;

    ierr = NMDObjectAllocateNewCategory
      (nmd,"cat2",&cat); NMD_ERR_RETURN(ierr);

    ierr = NMDCategoryAllocateNewComponent
      (cat,"p1",NMDInt,NULL); NMD_ERR_RETURN(ierr);
    ierr = NMDCategoryAllocateNewComponent
      (cat,"ptwo",NMDReal,NULL); NMD_ERR_RETURN(ierr);

    /* this call will make the program abort
       because of the type mismatch */
    printf("Type mismatch error coming up:\n\n");
    ierr = NMDCategoryGetOrCreateComponent
      (cat,"p1",NMDString,NULL); NMD_ERR_RETURN(ierr);
    ierr = NMDCategoryGetOrCreateComponent
      (cat,"ptwo",NMDReal,&cmp); NMD_ERR_RETURN(ierr);

  }

  ierr = NMDDestroyObject(nmd); NMD_ERR_RETURN(ierr);
  PetscFinalize();
  PetscFunctionReturn(0);
}

Here is the call graph for this function: