/*
 * exph5_select_simple
 * This example creates a select type that is a selection of the defined types 
 * all with the same underlying simple datatype.
 */


#include "hdf5.h"
#include "hdf5_hl.h"

int
main(void)
{
    hid_t    file, pop1_group, schema_group, pos_int, big_int, either_int;
    herr_t    status;

    /*
     * Create a new HDF5 file.
     */
    file = H5Fcreate("exph5_select_simple.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    /*
     * Create a data and schema group in the file and set required attributes and a decription.
     */
    pop1_group = H5Gcreate(file, "/Pop1", 0);
    schema_group = H5Gcreate(file, "/geometry_encoding1", 0);
    status =  H5LTset_attribute_string( pop1_group, "/Pop1", "iso_10303_26_data", "geometry" );
    status =  H5LTset_attribute_string( schema_group, "/geometry_encoding1", "iso_10303_26_schema", "geometry" );
    status =  H5LTset_attribute_string( schema_group, "/geometry_encoding1", "iso_10303_26_description", 
              "Contains example select type of defined types with same underlying simple datatype." );

 /* Add examples of TYPE <name> = <simple type>  */
    pos_int = H5Tcopy (H5T_NATIVE_INT);
    status = H5Tcommit (schema_group, "positive_integer", pos_int);

    big_int = H5Tcopy (H5T_NATIVE_INT);
    status = H5Tcommit (schema_group, "big_positive_integer", big_int);

/* Add example of TYPE <name> = SELECT <type of simple datatype, type of simple datatype> */
    either_int = H5Tcopy (H5T_NATIVE_INT);
    status = H5Tcommit (schema_group, "big_or_positive_integer", either_int);

    H5Tclose(pos_int);
    H5Tclose(big_int);
    H5Tclose(either_int);
    H5Gclose(pop1_group);
    H5Gclose(schema_group);
    H5Fclose(file);

}

