Back to index

salome-kernel  6.5.0
test8.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
00024 //  File   : test8.cxx
00025 //  Module : SALOME
00026 //
00027 #include <iostream.h>
00028 #include "HDFOI.hxx"
00029 #include <stdlib.h>
00030 
00031 
00032 int main()
00033 {
00034   HDFfile *hdf_file;
00035   HDFgroup *hdf_group;
00036   HDFdataset *hdf_dataset;
00037   hdf_size size[1];
00038   char message[HDF_NAME_MAX_LEN+1] = "MESSAGE";
00039   hdf_int32 attribute = 3;
00040 
00041   system("rm file_ascii.hdf");
00042 
00043   try
00044     {
00045       // a new HDFfile object
00046       hdf_file = new HDFfile("file_ascii.hdf");
00047       MESSAGE( ">> A HDFfile object is created" );
00048       
00049       hdf_file->CreateOnDisk();
00050       MESSAGE( ">> The HDF file is created on Disk " );
00051 
00052       // Inside the HDF file 
00053 
00054       // A new HDF group object
00055       hdf_group = new HDFgroup("ASCII GROUP",hdf_file);
00056       MESSAGE( ">> A HDFgroup object 'ASCII' is created" );
00057 
00058       hdf_group->CreateOnDisk();
00059       MESSAGE( ">> The HDF group is created on Disk " );
00060 
00061       // Transfert d'un fichier ASCII dans un groupe HDF
00062       HDFConvert::FromAscii("ascii.txt",*hdf_group,"ASCII DATASET");
00063       MESSAGE( ">> The Ascii file is transfered " );
00064  
00065       // The HDF group is built, it can be closed
00066       hdf_group->CloseOnDisk();
00067       MESSAGE( ">> The HDF group is closed on Disk " );
00068 
00069       // The HDF file is built, it can be closed
00070       hdf_file->CloseOnDisk();
00071       MESSAGE( ">> The HDF file is closed on disk" );
00072 
00073  
00074       delete hdf_group;
00075       MESSAGE( ">> The HDF group object is deleted" ); 
00076       delete hdf_file;
00077       MESSAGE( ">> The HDF file object is deleted" );
00078     }
00079   catch (HDFexception)
00080     {
00081       MESSAGE( "!!!! HDFexception" )
00082     }
00083 
00084   return 0;
00085 }