11 HDFdataset *hdf_dataset;
12 HDFdataset *hdf_dataset2;
13 HDFattribute *hdf_attribute;
15 hdf_float64 coordinates[3] = {5.,-6.9,4.2};
16 hdf_int32 unit[3] = {0,0,0};
17 char message[HDF_NAME_MAX_LEN+1] = "MESSAGE";
18 hdf_int32 attribute = 3;
19 HDFexplorer *explorer;
20 HDFinternalObject *object;
22 system("rm file_test3.hdf");
26 // a new HDFfile object
27 hdf_file = new HDFfile("file_test3.hdf");
28 MESSAGE( ">> A HDFfile object is created" );
30 hdf_file->CreateOnDisk();
31 MESSAGE( ">> The HDF file is created on Disk " );
33 // Inside the HDF file
35 // A new HDF group object
36 hdf_group = new HDFgroup("MESH",hdf_file);
37 MESSAGE( ">> A HDFgroup object 'MESH' is created" );
39 hdf_group->CreateOnDisk();
40 MESSAGE( ">> The HDF group is created on Disk " );
42 // Inside the HDF group
44 // A new HDF dataset object
45 // size of each dimension, only one in the example
47 hdf_dataset = new HDFdataset("COORDINATES",hdf_group,HDF_FLOAT64,size,1);
48 MESSAGE( ">> A HDFdataset object 'COORDINATES' is created" );
50 hdf_dataset->CreateOnDisk();
51 MESSAGE( ">> The HDF dataset is created on Disk " );
53 // a HDFattribute object inside the dataset
54 hdf_attribute = new HDFattribute("ATTRIBUTE",hdf_dataset,HDF_INT32);
55 MESSAGE( ">> A HDF attribute object is created for the dataset " );
57 hdf_dataset->WriteOnDisk(coordinates);
58 MESSAGE( ">> The HDF dataset is written on Disk " );
60 hdf_attribute->CreateOnDisk();
61 MESSAGE( ">> The HDF attribute is created on Disk " );
63 hdf_attribute->WriteOnDisk(&attribute);
64 MESSAGE( ">> The HDF attribute is written on Disk " );
66 hdf_attribute->CloseOnDisk();
67 MESSAGE( ">> The HDF attribute closed on Disk " );
69 hdf_dataset->CloseOnDisk();
70 MESSAGE( ">> The HDF dataset is closed on Disk " );
72 // A new dataset is created
74 hdf_dataset2 = new HDFdataset("UNIT",hdf_group,HDF_INT32,size,1);
75 MESSAGE( ">> A second HDFdataset object 'UNIT' is created" );
77 hdf_dataset2->CreateOnDisk();
78 MESSAGE( ">> The HDF dataset is created on Disk " );
80 hdf_dataset2->WriteOnDisk(unit);
81 MESSAGE( ">> The HDF dataset is written on Disk " );
83 hdf_dataset2->CloseOnDisk();
84 MESSAGE( ">> The HDF dataset is closed on Disk " );
86 // The HDF group is built, it can be closed
87 hdf_group->CloseOnDisk();
88 MESSAGE( ">> The HDF group is closed on Disk " );
90 // The HDF file is built, it can be closed
91 hdf_file->CloseOnDisk();
92 MESSAGE( ">> The HDF file is closed on disk" );
95 explorer = new HDFexplorer(hdf_file);
96 MESSAGE( ">> A HDF explorer object is created" );
98 MESSAGE( ">> File Exploration " );
99 for (explorer->Init();explorer->More();explorer->Next())
101 object = explorer->Value();
102 MESSAGE( "--> Name of the object : " << object->GetName() );
103 switch (object->GetObjectType())
106 MESSAGE( "--> Type of the object : HDF_FILE : " );
110 MESSAGE( "--> Type of the object : HDF_GROUP : " );
114 MESSAGE( "--> Type of the object : HDF_DATASET : " );
118 MESSAGE( "--> PANIC !!! : " );
122 MESSAGE( ">> Group exploration" );
123 explorer->Reset(hdf_group);
124 for (explorer->Init();explorer->More();explorer->Next())
126 object = explorer->Value();
127 MESSAGE( "--> Name of the object : " << object->GetName() );
128 switch (object->GetObjectType())
131 MESSAGE( "--> Type of the object : HDF_FILE : " );
135 MESSAGE( "--> Type of the object : HDF_GROUP : " );
139 MESSAGE( "--> Type of the object : HDF_DATASET : " );
143 MESSAGE( "--> !!! PANIC !!! : " );
148 MESSAGE( ">> MEMORY CLEAN " );
150 MESSAGE( ">> The HDF eplorer object is deleted" );
151 delete hdf_attribute;
152 MESSAGE( ">> The HDF attribute object is deleted" );
154 MESSAGE( ">> The first HDF dataset object is deleted" );
156 MESSAGE( ">> The second HDF dataset object is deleted" );
158 MESSAGE( ">> The HDF group object is deleted" );
160 MESSAGE( ">> The HDF file object is deleted" );
164 MESSAGE( "!!!! HDFexception" )