HDF5: can now extract info and data from objects 30/9030/8
Calixte DENIZET [Mon, 17 Sep 2012 14:20:49 +0000 (16:20 +0200)]
Change-Id: Ie20bc0daebfae2bfec4a4f04bf8a8604df1501fd

75 files changed:
scilab/modules/hdf5/Makefile.am
scilab/modules/hdf5/Makefile.in
scilab/modules/hdf5/includes/HDF5Objects.h
scilab/modules/hdf5/includes/gw_hdf5.h
scilab/modules/hdf5/sci_gateway/c/gw_hdf5.c
scilab/modules/hdf5/sci_gateway/cpp/sci_h5attr.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5close.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5dataset.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5delete.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5dump.cpp
scilab/modules/hdf5/sci_gateway/cpp/sci_h5group.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5link.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5ls.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5open.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5read.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_h5readattr.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_e.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_p.cpp [new file with mode: 0644]
scilab/modules/hdf5/sci_gateway/hdf5_gateway.xml
scilab/modules/hdf5/src/cpp/H5Attribute.cpp
scilab/modules/hdf5/src/cpp/H5Attribute.hxx
scilab/modules/hdf5/src/cpp/H5AttributesList.cpp
scilab/modules/hdf5/src/cpp/H5AttributesList.hxx
scilab/modules/hdf5/src/cpp/H5BasicData.hxx
scilab/modules/hdf5/src/cpp/H5BitfieldData.hxx
scilab/modules/hdf5/src/cpp/H5CharData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5CompoundData.hxx
scilab/modules/hdf5/src/cpp/H5Data.hxx
scilab/modules/hdf5/src/cpp/H5DataConverter.cpp
scilab/modules/hdf5/src/cpp/H5DataConverter.hxx
scilab/modules/hdf5/src/cpp/H5DataFactory.cpp
scilab/modules/hdf5/src/cpp/H5DataFactory.hxx
scilab/modules/hdf5/src/cpp/H5Dataset.cpp
scilab/modules/hdf5/src/cpp/H5Dataset.hxx
scilab/modules/hdf5/src/cpp/H5DatasetsList.cpp
scilab/modules/hdf5/src/cpp/H5DatasetsList.hxx
scilab/modules/hdf5/src/cpp/H5Dataspace.cpp
scilab/modules/hdf5/src/cpp/H5Dataspace.hxx
scilab/modules/hdf5/src/cpp/H5EnumData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Exception.hxx
scilab/modules/hdf5/src/cpp/H5ExternalLink.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5ExternalLink.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5File.cpp
scilab/modules/hdf5/src/cpp/H5File.hxx
scilab/modules/hdf5/src/cpp/H5FloatData.hxx
scilab/modules/hdf5/src/cpp/H5Group.cpp
scilab/modules/hdf5/src/cpp/H5Group.hxx
scilab/modules/hdf5/src/cpp/H5GroupsList.cpp
scilab/modules/hdf5/src/cpp/H5GroupsList.hxx
scilab/modules/hdf5/src/cpp/H5HardLink.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5HardLink.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Link.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5Link.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5LinksList.cpp
scilab/modules/hdf5/src/cpp/H5LinksList.hxx
scilab/modules/hdf5/src/cpp/H5ListObject.hxx
scilab/modules/hdf5/src/cpp/H5NamedObjectsList.hxx
scilab/modules/hdf5/src/cpp/H5Object.cpp
scilab/modules/hdf5/src/cpp/H5Object.hxx
scilab/modules/hdf5/src/cpp/H5OpaqueData.hxx
scilab/modules/hdf5/src/cpp/H5ReferenceData.hxx
scilab/modules/hdf5/src/cpp/H5SoftLink.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5SoftLink.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5SoftLinksList.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5StringData.hxx
scilab/modules/hdf5/src/cpp/H5TimeData.hxx
scilab/modules/hdf5/src/cpp/H5Type.cpp
scilab/modules/hdf5/src/cpp/H5Type.hxx
scilab/modules/hdf5/src/cpp/H5TypesList.hxx
scilab/modules/hdf5/src/cpp/H5UnsignedCharData.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5VariableScope.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/H5VariableScope.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/HDF5Scilab.cpp [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/HDF5Scilab.hxx [new file with mode: 0644]
scilab/modules/hdf5/src/cpp/h5create.hpp [new file with mode: 0644]

index 4f42bc7..a2463f9 100644 (file)
@@ -32,7 +32,13 @@ HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
                   src/cpp/H5LinksList.cpp \
                   src/cpp/H5Object.cpp \
                   src/cpp/H5Type.cpp \
-                  src/cpp/H5DataFactory.cpp
+                  src/cpp/H5DataFactory.cpp \
+                  src/cpp/H5VariableScope.cpp \
+                  src/cpp/H5SoftLink.cpp \
+                  src/cpp/H5ExternalLink.cpp \
+                  src/cpp/H5HardLink.cpp \
+                  src/cpp/H5Link.cpp \
+                  src/cpp/HDF5Scilab.cpp
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
 
@@ -40,7 +46,19 @@ GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_export_to_hdf5.cpp \
 sci_gateway/cpp/sci_import_from_hdf5.cpp \
 sci_gateway/cpp/sci_is_hdf5_file.cpp \
 sci_gateway/cpp/sci_listvar_in_hdf5.cpp \
-sci_gateway/cpp/sci_h5dump.cpp
+sci_gateway/cpp/sci_h5dump.cpp \
+sci_gateway/cpp/sci_h5open.cpp \
+sci_gateway/cpp/sci_h5close.cpp \
+sci_gateway/cpp/sci_h5read.cpp \
+sci_gateway/cpp/sci_h5ls.cpp \
+sci_gateway/cpp/sci_percent_H5Object_p.cpp \
+sci_gateway/cpp/sci_percent_H5Object_e.cpp \
+sci_gateway/cpp/sci_h5group.cpp \
+sci_gateway/cpp/sci_h5delete.cpp \
+sci_gateway/cpp/sci_h5dataset.cpp \
+sci_gateway/cpp/sci_h5attr.cpp \
+sci_gateway/cpp/sci_h5link.cpp \
+sci_gateway/cpp/sci_h5readattr.cpp
 
 if GIWS
 BUILT_SOURCES=giws
index ac6ef85..6f2ee69 100644 (file)
@@ -152,7 +152,12 @@ am__objects_2 = libscihdf5_algo_la-H5Attribute.lo \
        libscihdf5_algo_la-H5Group.lo \
        libscihdf5_algo_la-H5LinksList.lo \
        libscihdf5_algo_la-H5Object.lo libscihdf5_algo_la-H5Type.lo \
-       libscihdf5_algo_la-H5DataFactory.lo
+       libscihdf5_algo_la-H5DataFactory.lo \
+       libscihdf5_algo_la-H5VariableScope.lo \
+       libscihdf5_algo_la-H5SoftLink.lo \
+       libscihdf5_algo_la-H5ExternalLink.lo \
+       libscihdf5_algo_la-H5HardLink.lo libscihdf5_algo_la-H5Link.lo \
+       libscihdf5_algo_la-HDF5Scilab.lo
 am_libscihdf5_algo_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libscihdf5_algo_la_OBJECTS = $(am_libscihdf5_algo_la_OBJECTS)
 libscihdf5_la_DEPENDENCIES = libscihdf5-algo.la
@@ -160,7 +165,14 @@ am__objects_3 = libscihdf5_la-sci_export_to_hdf5.lo \
        libscihdf5_la-sci_import_from_hdf5.lo \
        libscihdf5_la-sci_is_hdf5_file.lo \
        libscihdf5_la-sci_listvar_in_hdf5.lo \
-       libscihdf5_la-sci_h5dump.lo
+       libscihdf5_la-sci_h5dump.lo libscihdf5_la-sci_h5open.lo \
+       libscihdf5_la-sci_h5close.lo libscihdf5_la-sci_h5read.lo \
+       libscihdf5_la-sci_h5ls.lo \
+       libscihdf5_la-sci_percent_H5Object_p.lo \
+       libscihdf5_la-sci_percent_H5Object_e.lo \
+       libscihdf5_la-sci_h5group.lo libscihdf5_la-sci_h5delete.lo \
+       libscihdf5_la-sci_h5dataset.lo libscihdf5_la-sci_h5attr.lo \
+       libscihdf5_la-sci_h5link.lo libscihdf5_la-sci_h5readattr.lo
 am__objects_4 = libscihdf5_la-gw_hdf5.lo
 am_libscihdf5_la_OBJECTS = $(am__objects_3) $(am__objects_4)
 libscihdf5_la_OBJECTS = $(am_libscihdf5_la_OBJECTS)
@@ -474,14 +486,32 @@ HDF5_CXX_SOURCES = src/cpp/H5Attribute.cpp \
                   src/cpp/H5LinksList.cpp \
                   src/cpp/H5Object.cpp \
                   src/cpp/H5Type.cpp \
-                  src/cpp/H5DataFactory.cpp
+                  src/cpp/H5DataFactory.cpp \
+                  src/cpp/H5VariableScope.cpp \
+                  src/cpp/H5SoftLink.cpp \
+                  src/cpp/H5ExternalLink.cpp \
+                  src/cpp/H5HardLink.cpp \
+                  src/cpp/H5Link.cpp \
+                  src/cpp/HDF5Scilab.cpp
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_hdf5.c
 GATEWAY_CXX_SOURCES = sci_gateway/cpp/sci_export_to_hdf5.cpp \
 sci_gateway/cpp/sci_import_from_hdf5.cpp \
 sci_gateway/cpp/sci_is_hdf5_file.cpp \
 sci_gateway/cpp/sci_listvar_in_hdf5.cpp \
-sci_gateway/cpp/sci_h5dump.cpp
+sci_gateway/cpp/sci_h5dump.cpp \
+sci_gateway/cpp/sci_h5open.cpp \
+sci_gateway/cpp/sci_h5close.cpp \
+sci_gateway/cpp/sci_h5read.cpp \
+sci_gateway/cpp/sci_h5ls.cpp \
+sci_gateway/cpp/sci_percent_H5Object_p.cpp \
+sci_gateway/cpp/sci_percent_H5Object_e.cpp \
+sci_gateway/cpp/sci_h5group.cpp \
+sci_gateway/cpp/sci_h5delete.cpp \
+sci_gateway/cpp/sci_h5dataset.cpp \
+sci_gateway/cpp/sci_h5attr.cpp \
+sci_gateway/cpp/sci_h5link.cpp \
+sci_gateway/cpp/sci_h5readattr.cpp
 
 @GIWS_TRUE@BUILT_SOURCES = giws
 
@@ -756,11 +786,17 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5DataFactory.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Dataset.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Dataspace.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5ExternalLink.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5File.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Group.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5HardLink.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Link.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5LinksList.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Object.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5SoftLink.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5Type.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-H5VariableScope.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-HDF5Scilab.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-h5_fileManagement.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-h5_readDataFromFile.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-h5_readDataFromFile_v1.Plo@am__quote@
@@ -769,10 +805,22 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_algo_la-listvar_in_hdf5_v1.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-gw_hdf5.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5attr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5close.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5dataset.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5delete.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5dump.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5group.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5link.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5ls.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5open.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5read.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_h5readattr.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_import_from_hdf5.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_is_hdf5_file.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_listvar_in_hdf5.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_percent_H5Object_e.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscihdf5_la-sci_percent_H5Object_p.Plo@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -942,6 +990,48 @@ libscihdf5_algo_la-H5DataFactory.lo: src/cpp/H5DataFactory.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5DataFactory.lo `test -f 'src/cpp/H5DataFactory.cpp' || echo '$(srcdir)/'`src/cpp/H5DataFactory.cpp
 
+libscihdf5_algo_la-H5VariableScope.lo: src/cpp/H5VariableScope.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5VariableScope.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5VariableScope.Tpo -c -o libscihdf5_algo_la-H5VariableScope.lo `test -f 'src/cpp/H5VariableScope.cpp' || echo '$(srcdir)/'`src/cpp/H5VariableScope.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5VariableScope.Tpo $(DEPDIR)/libscihdf5_algo_la-H5VariableScope.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5VariableScope.cpp' object='libscihdf5_algo_la-H5VariableScope.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5VariableScope.lo `test -f 'src/cpp/H5VariableScope.cpp' || echo '$(srcdir)/'`src/cpp/H5VariableScope.cpp
+
+libscihdf5_algo_la-H5SoftLink.lo: src/cpp/H5SoftLink.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5SoftLink.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5SoftLink.Tpo -c -o libscihdf5_algo_la-H5SoftLink.lo `test -f 'src/cpp/H5SoftLink.cpp' || echo '$(srcdir)/'`src/cpp/H5SoftLink.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5SoftLink.Tpo $(DEPDIR)/libscihdf5_algo_la-H5SoftLink.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5SoftLink.cpp' object='libscihdf5_algo_la-H5SoftLink.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5SoftLink.lo `test -f 'src/cpp/H5SoftLink.cpp' || echo '$(srcdir)/'`src/cpp/H5SoftLink.cpp
+
+libscihdf5_algo_la-H5ExternalLink.lo: src/cpp/H5ExternalLink.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5ExternalLink.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5ExternalLink.Tpo -c -o libscihdf5_algo_la-H5ExternalLink.lo `test -f 'src/cpp/H5ExternalLink.cpp' || echo '$(srcdir)/'`src/cpp/H5ExternalLink.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5ExternalLink.Tpo $(DEPDIR)/libscihdf5_algo_la-H5ExternalLink.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5ExternalLink.cpp' object='libscihdf5_algo_la-H5ExternalLink.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5ExternalLink.lo `test -f 'src/cpp/H5ExternalLink.cpp' || echo '$(srcdir)/'`src/cpp/H5ExternalLink.cpp
+
+libscihdf5_algo_la-H5HardLink.lo: src/cpp/H5HardLink.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5HardLink.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5HardLink.Tpo -c -o libscihdf5_algo_la-H5HardLink.lo `test -f 'src/cpp/H5HardLink.cpp' || echo '$(srcdir)/'`src/cpp/H5HardLink.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5HardLink.Tpo $(DEPDIR)/libscihdf5_algo_la-H5HardLink.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5HardLink.cpp' object='libscihdf5_algo_la-H5HardLink.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5HardLink.lo `test -f 'src/cpp/H5HardLink.cpp' || echo '$(srcdir)/'`src/cpp/H5HardLink.cpp
+
+libscihdf5_algo_la-H5Link.lo: src/cpp/H5Link.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-H5Link.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-H5Link.Tpo -c -o libscihdf5_algo_la-H5Link.lo `test -f 'src/cpp/H5Link.cpp' || echo '$(srcdir)/'`src/cpp/H5Link.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-H5Link.Tpo $(DEPDIR)/libscihdf5_algo_la-H5Link.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/H5Link.cpp' object='libscihdf5_algo_la-H5Link.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-H5Link.lo `test -f 'src/cpp/H5Link.cpp' || echo '$(srcdir)/'`src/cpp/H5Link.cpp
+
+libscihdf5_algo_la-HDF5Scilab.lo: src/cpp/HDF5Scilab.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_algo_la-HDF5Scilab.lo -MD -MP -MF $(DEPDIR)/libscihdf5_algo_la-HDF5Scilab.Tpo -c -o libscihdf5_algo_la-HDF5Scilab.lo `test -f 'src/cpp/HDF5Scilab.cpp' || echo '$(srcdir)/'`src/cpp/HDF5Scilab.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_algo_la-HDF5Scilab.Tpo $(DEPDIR)/libscihdf5_algo_la-HDF5Scilab.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='src/cpp/HDF5Scilab.cpp' object='libscihdf5_algo_la-HDF5Scilab.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_algo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_algo_la-HDF5Scilab.lo `test -f 'src/cpp/HDF5Scilab.cpp' || echo '$(srcdir)/'`src/cpp/HDF5Scilab.cpp
+
 libscihdf5_la-sci_export_to_hdf5.lo: sci_gateway/cpp/sci_export_to_hdf5.cpp
 @am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_export_to_hdf5.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Tpo -c -o libscihdf5_la-sci_export_to_hdf5.lo `test -f 'sci_gateway/cpp/sci_export_to_hdf5.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_export_to_hdf5.cpp
 @am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Tpo $(DEPDIR)/libscihdf5_la-sci_export_to_hdf5.Plo
@@ -977,6 +1067,90 @@ libscihdf5_la-sci_h5dump.lo: sci_gateway/cpp/sci_h5dump.cpp
 @AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5dump.lo `test -f 'sci_gateway/cpp/sci_h5dump.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5dump.cpp
 
+libscihdf5_la-sci_h5open.lo: sci_gateway/cpp/sci_h5open.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5open.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5open.Tpo -c -o libscihdf5_la-sci_h5open.lo `test -f 'sci_gateway/cpp/sci_h5open.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5open.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5open.Tpo $(DEPDIR)/libscihdf5_la-sci_h5open.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5open.cpp' object='libscihdf5_la-sci_h5open.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5open.lo `test -f 'sci_gateway/cpp/sci_h5open.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5open.cpp
+
+libscihdf5_la-sci_h5close.lo: sci_gateway/cpp/sci_h5close.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5close.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5close.Tpo -c -o libscihdf5_la-sci_h5close.lo `test -f 'sci_gateway/cpp/sci_h5close.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5close.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5close.Tpo $(DEPDIR)/libscihdf5_la-sci_h5close.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5close.cpp' object='libscihdf5_la-sci_h5close.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5close.lo `test -f 'sci_gateway/cpp/sci_h5close.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5close.cpp
+
+libscihdf5_la-sci_h5read.lo: sci_gateway/cpp/sci_h5read.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5read.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5read.Tpo -c -o libscihdf5_la-sci_h5read.lo `test -f 'sci_gateway/cpp/sci_h5read.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5read.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5read.Tpo $(DEPDIR)/libscihdf5_la-sci_h5read.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5read.cpp' object='libscihdf5_la-sci_h5read.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5read.lo `test -f 'sci_gateway/cpp/sci_h5read.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5read.cpp
+
+libscihdf5_la-sci_h5ls.lo: sci_gateway/cpp/sci_h5ls.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5ls.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5ls.Tpo -c -o libscihdf5_la-sci_h5ls.lo `test -f 'sci_gateway/cpp/sci_h5ls.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5ls.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5ls.Tpo $(DEPDIR)/libscihdf5_la-sci_h5ls.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5ls.cpp' object='libscihdf5_la-sci_h5ls.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5ls.lo `test -f 'sci_gateway/cpp/sci_h5ls.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5ls.cpp
+
+libscihdf5_la-sci_percent_H5Object_p.lo: sci_gateway/cpp/sci_percent_H5Object_p.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_percent_H5Object_p.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_p.Tpo -c -o libscihdf5_la-sci_percent_H5Object_p.lo `test -f 'sci_gateway/cpp/sci_percent_H5Object_p.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_H5Object_p.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_p.Tpo $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_p.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_percent_H5Object_p.cpp' object='libscihdf5_la-sci_percent_H5Object_p.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_percent_H5Object_p.lo `test -f 'sci_gateway/cpp/sci_percent_H5Object_p.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_H5Object_p.cpp
+
+libscihdf5_la-sci_percent_H5Object_e.lo: sci_gateway/cpp/sci_percent_H5Object_e.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_percent_H5Object_e.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_e.Tpo -c -o libscihdf5_la-sci_percent_H5Object_e.lo `test -f 'sci_gateway/cpp/sci_percent_H5Object_e.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_H5Object_e.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_e.Tpo $(DEPDIR)/libscihdf5_la-sci_percent_H5Object_e.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_percent_H5Object_e.cpp' object='libscihdf5_la-sci_percent_H5Object_e.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_percent_H5Object_e.lo `test -f 'sci_gateway/cpp/sci_percent_H5Object_e.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_percent_H5Object_e.cpp
+
+libscihdf5_la-sci_h5group.lo: sci_gateway/cpp/sci_h5group.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5group.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5group.Tpo -c -o libscihdf5_la-sci_h5group.lo `test -f 'sci_gateway/cpp/sci_h5group.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5group.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5group.Tpo $(DEPDIR)/libscihdf5_la-sci_h5group.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5group.cpp' object='libscihdf5_la-sci_h5group.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5group.lo `test -f 'sci_gateway/cpp/sci_h5group.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5group.cpp
+
+libscihdf5_la-sci_h5delete.lo: sci_gateway/cpp/sci_h5delete.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5delete.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5delete.Tpo -c -o libscihdf5_la-sci_h5delete.lo `test -f 'sci_gateway/cpp/sci_h5delete.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5delete.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5delete.Tpo $(DEPDIR)/libscihdf5_la-sci_h5delete.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5delete.cpp' object='libscihdf5_la-sci_h5delete.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5delete.lo `test -f 'sci_gateway/cpp/sci_h5delete.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5delete.cpp
+
+libscihdf5_la-sci_h5dataset.lo: sci_gateway/cpp/sci_h5dataset.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5dataset.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5dataset.Tpo -c -o libscihdf5_la-sci_h5dataset.lo `test -f 'sci_gateway/cpp/sci_h5dataset.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5dataset.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5dataset.Tpo $(DEPDIR)/libscihdf5_la-sci_h5dataset.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5dataset.cpp' object='libscihdf5_la-sci_h5dataset.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5dataset.lo `test -f 'sci_gateway/cpp/sci_h5dataset.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5dataset.cpp
+
+libscihdf5_la-sci_h5attr.lo: sci_gateway/cpp/sci_h5attr.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5attr.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5attr.Tpo -c -o libscihdf5_la-sci_h5attr.lo `test -f 'sci_gateway/cpp/sci_h5attr.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5attr.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5attr.Tpo $(DEPDIR)/libscihdf5_la-sci_h5attr.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5attr.cpp' object='libscihdf5_la-sci_h5attr.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5attr.lo `test -f 'sci_gateway/cpp/sci_h5attr.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5attr.cpp
+
+libscihdf5_la-sci_h5link.lo: sci_gateway/cpp/sci_h5link.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5link.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5link.Tpo -c -o libscihdf5_la-sci_h5link.lo `test -f 'sci_gateway/cpp/sci_h5link.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5link.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5link.Tpo $(DEPDIR)/libscihdf5_la-sci_h5link.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5link.cpp' object='libscihdf5_la-sci_h5link.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5link.lo `test -f 'sci_gateway/cpp/sci_h5link.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5link.cpp
+
+libscihdf5_la-sci_h5readattr.lo: sci_gateway/cpp/sci_h5readattr.cpp
+@am__fastdepCXX_TRUE@  $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscihdf5_la-sci_h5readattr.lo -MD -MP -MF $(DEPDIR)/libscihdf5_la-sci_h5readattr.Tpo -c -o libscihdf5_la-sci_h5readattr.lo `test -f 'sci_gateway/cpp/sci_h5readattr.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5readattr.cpp
+@am__fastdepCXX_TRUE@  $(am__mv) $(DEPDIR)/libscihdf5_la-sci_h5readattr.Tpo $(DEPDIR)/libscihdf5_la-sci_h5readattr.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     source='sci_gateway/cpp/sci_h5readattr.cpp' object='libscihdf5_la-sci_h5readattr.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@     DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscihdf5_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscihdf5_la-sci_h5readattr.lo `test -f 'sci_gateway/cpp/sci_h5readattr.cpp' || echo '$(srcdir)/'`sci_gateway/cpp/sci_h5readattr.cpp
+
 mostlyclean-libtool:
        -rm -f *.lo
 
index 5c87892..3894031 100644 (file)
@@ -1 +1,22 @@
-#define HDF5OBJECTS_DEBUG
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __HDF5OBJECTS_H__
+#define __HDF5OBJECTS_H__
+
+#define __HDF5OBJECTS_DEBUG__
+#define __HDF5ERROR_PRINT__
+
+#define __SCILAB_MLIST_H5OBJECT__ "H5Object"
+#define __SCILAB_HDF5_MAX_DIMS__ 64
+
+#endif // __HDF5OBJECTS_H__
index 58b2574..e9f8849 100644 (file)
@@ -1,27 +1,39 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Allan CORNET
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #ifndef __GW_HDF5_H__
 #define __GW_HDF5_H__
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 #include "dynlib_hdf5_scilab.h"
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 HDF5_SCILAB_IMPEXP int gw_hdf5(void);
-/*--------------------------------------------------------------------------*/ 
-HDF5_SCILAB_IMPEXP int sci_export_to_hdf5(char *fname,unsigned long fname_len);
-HDF5_SCILAB_IMPEXP int sci_import_from_hdf5(char *fname,unsigned long fname_len);
-HDF5_SCILAB_IMPEXP int sci_listvar_in_hdf5(char *fname,unsigned long fname_len);
-HDF5_SCILAB_IMPEXP int sci_is_hdf5_file(char *fname,unsigned long fname_len);
-HDF5_SCILAB_IMPEXP int sci_h5dump(char *fname,unsigned long fname_len);
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
+HDF5_SCILAB_IMPEXP int sci_export_to_hdf5(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_import_from_hdf5(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_listvar_in_hdf5(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_is_hdf5_file(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5dump(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5open(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5close(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5read(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5ls(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_percent_H5Object_p(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_percent_H5Object_e(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5group(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5delete(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5dataset(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5attr(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5link(char *fname, unsigned long fname_len);
+HDF5_SCILAB_IMPEXP int sci_h5readattr(char *fname, unsigned long fname_len);
+/*--------------------------------------------------------------------------*/
 #endif /* __GW_HDF5_H__ */
 /*--------------------------------------------------------------------------*/
index b7b638d..d17371d 100644 (file)
@@ -1,11 +1,12 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Allan CORNET
- * 
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 #include "api_scilab.h"
 #include "MALLOC.h"
 
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 /*  interface function */
-/*--------------------------------------------------------------------------*/ 
-static gw_generic_table Tab[] = 
+/*--------------------------------------------------------------------------*/
+static gw_generic_table Tab[] =
 {
-       {sci_export_to_hdf5, "export_to_hdf5"},
-       {sci_import_from_hdf5, "import_from_hdf5"},
-       {sci_listvar_in_hdf5, "listvar_in_hdf5"},
-       {sci_is_hdf5_file, "is_hdf5_file"},
-       {sci_h5dump, "h5dump"}
+    {sci_export_to_hdf5, "export_to_hdf5"},
+    {sci_import_from_hdf5, "import_from_hdf5"},
+    {sci_listvar_in_hdf5, "listvar_in_hdf5"},
+    {sci_is_hdf5_file, "is_hdf5_file"},
+    {sci_h5dump, "h5dump"},
+    {sci_h5open, "h5open"},
+    {sci_h5close, "h5close"},
+    {sci_h5read, "h5read"},
+    {sci_h5ls, "h5ls"},
+    {sci_percent_H5Object_p, "%H5Object_p"},
+    {sci_percent_H5Object_e, "%H5Object_e"},
+    {sci_h5group, "h5group"},
+    {sci_h5delete, "h5delete"},
+    {sci_h5dataset, "h5dataset"},
+    {sci_h5attr, "h5attr"},
+    {sci_h5link, "h5link"},
+    {sci_h5readattr, "h5readattr"},
 };
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 int gw_hdf5(void)
 {
-       Rhs = Max(0,Rhs);
+    Rhs = Max(0, Rhs);
 
-       if(pvApiCtx == NULL)
-       {
-               pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
-       }
+    if (pvApiCtx == NULL)
+    {
+        pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
+    }
 
-       pvApiCtx->pstName = (char*)Tab[Fin-1].name;
-       callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
-       return 0;
+    pvApiCtx->pstName = (char*)Tab[Fin - 1].name;
+    callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
+    return 0;
 }
-/*--------------------------------------------------------------------------*/ 
+/*--------------------------------------------------------------------------*/
 
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5attr.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5attr.cpp
new file mode 100644 (file)
index 0000000..ec3eaf2
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "h5create.hpp"
+
+using namespace org_modules_hdf5;
+
+int sci_h5attr(char *fname, unsigned long fname_len)
+{
+    return h5create<H5Attribute>(fname, fname_len);
+}
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5close.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5close.cpp
new file mode 100644 (file)
index 0000000..d8e8339
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Exception.hxx"
+#include "HDF5Scilab.hxx"
+#include "H5Object.hxx"
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "sciprint.h"
+#include "localization.h"
+}
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5close(char *fname, unsigned long fname_len)
+{
+    int id;
+    SciErr err;
+    int * addr = 0;
+
+    if (Rhs == 0)
+    {
+        H5Object::cleanAll();
+    }
+    else
+    {
+        for (unsigned int i = 1; i <= Rhs; i++)
+        {
+            err = getVarAddressFromPosition(pvApiCtx, i, &addr);
+            if (err.iErr)
+            {
+                printError(&err, 0);
+                Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, i);
+                return 0;
+            }
+
+            try
+            {
+                id = HDF5Scilab::getH5ObjectId(addr, pvApiCtx);
+                H5VariableScope::removeIdAndDelete(id);
+            }
+            catch (std::exception & e)
+            {
+                Scierror(999, _("%s: Cannot remove H5Object.\n"), fname);
+                return 0;
+            }
+        }
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5dataset.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5dataset.cpp
new file mode 100644 (file)
index 0000000..73a1e39
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "h5create.hpp"
+
+using namespace org_modules_hdf5;
+
+int sci_h5dataset(char *fname, unsigned long fname_len)
+{
+    return h5create<H5Dataset>(fname, fname_len);
+}
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5delete.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5delete.cpp
new file mode 100644 (file)
index 0000000..46fd94d
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include <set>
+#include <string>
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "expandPathVariable.h"
+}
+
+#include "HDF5Scilab.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5delete(char *fname, unsigned long fname_len)
+{
+    H5Object * hobj = 0;
+    SciErr err;
+    int * addr = 0;
+    char * name = 0;
+
+    CheckLhs(1, 1);
+    CheckRhs(2, 2);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
+    {
+        hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!hobj)
+        {
+            Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        Scierror(999, _("%s: Invalid input argument #%d: a H5Object expected.\n"), fname, 1);
+    }
+
+    err = getVarAddressFromPosition(pvApiCtx, 2, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+        return 0;
+    }
+
+    if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+    {
+        Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 2);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, addr, &name) != 0)
+    {
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+    try
+    {
+        HDF5Scilab::deleteLink(*hobj, std::string(name));
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        return 0;
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
index b8b7e0a..251e9f2 100644 (file)
@@ -10,6 +10,9 @@
  *
  */
 
+#include <set>
+#include <string>
+
 extern "C"
 {
 #include "gw_hdf5.h"
@@ -17,8 +20,10 @@ extern "C"
 #include "api_scilab.h"
 #include "localization.h"
 #include "sciprint.h"
+#include "expandPathVariable.h"
 }
 
+#include "HDF5Scilab.hxx"
 #include "H5File.hxx"
 
 using namespace org_modules_hdf5;
@@ -26,13 +31,40 @@ using namespace org_modules_hdf5;
 /*--------------------------------------------------------------------------*/
 int sci_h5dump(char *fname, unsigned long fname_len)
 {
-    H5File * h5file = 0;
+    H5Object * hobj = 0;
     SciErr err;
     int * addr = 0;
     char * path = 0;
+    char * expandedPath = 0;
+    char * name = 0;
+    std::map<haddr_t, std::string> visited;
+    bool mustDelete = true;
 
     CheckLhs(1, 1);
-    CheckRhs(1, 1);
+    CheckRhs(1, 2);
+
+    if (Rhs == 2)
+    {
+        err = getVarAddressFromPosition(pvApiCtx, 2, &addr);
+        if (err.iErr)
+        {
+            printError(&err, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+            return 0;
+        }
+
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 2);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &name) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+    }
 
     err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
     if (err.iErr)
@@ -42,41 +74,83 @@ int sci_h5dump(char *fname, unsigned long fname_len)
         return 0;
     }
 
-    if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
     {
-        Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
-        return 0;
-    }
+        hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!hobj)
+        {
+            Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+            return 0;
+        }
 
-    if (getAllocatedSingleString(pvApiCtx, addr, &path) != 0)
-    {
-        Scierror(999, _("%s: No more memory.\n"), fname);
-        return 0;
+        if (Rhs == 2)
+        {
+            try
+            {
+                hobj = &H5Object::getObject(*hobj, name);
+            }
+            catch (H5Exception & e)
+            {
+                Scierror(999, gettext("%s: %s\n"), fname, e.what());
+                return 0;
+            }
+        }
+        else
+        {
+            mustDelete = false;
+        }
     }
-
-
-    try
+    else
     {
-       h5file = new H5File((const char *)path);
-       freeAllocatedSingleString(path);
-    }
-    catch (const H5Exception & e)
-    {
-       Scierror(999, _("%s: %s\n"), fname, e.what());
-       freeAllocatedSingleString(path);
-       return 0;
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &path) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+        expandedPath = expandPathVariable(path);
+        freeAllocatedSingleString(path);
+        try
+        {
+            if (Rhs == 2)
+            {
+                hobj = new H5File((const char *)expandedPath, (const char *)name, "r");
+            }
+            else
+            {
+                hobj = new H5File((const char *)expandedPath, "/", "r");
+            }
+            FREE(expandedPath);
+        }
+        catch (const H5Exception & e)
+        {
+            Scierror(999, _("%s: %s\n"), fname, e.what());
+            FREE(expandedPath);
+            return 0;
+        }
     }
 
     try
     {
-       sciprint("%s\n", h5file->toString(0).c_str());
-       delete h5file;
+        HDF5Scilab::scilabPrint(hobj->dump(visited));
+        if (mustDelete)
+        {
+            delete hobj;
+        }
     }
-     catch (const H5Exception & e)
+    catch (const H5Exception & e)
     {
-       Scierror(999, _("%s: %s\n"), fname, e.what());
-       delete h5file;
-       return 0;
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        if (mustDelete)
+        {
+            delete hobj;
+        }
+        return 0;
     }
 
     LhsVar(1) = 0;
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5group.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5group.cpp
new file mode 100644 (file)
index 0000000..173d9d3
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include <string>
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+}
+
+#include "H5Group.hxx"
+#include "HDF5Scilab.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5group(char *fname, unsigned long fname_len)
+{
+    H5Object * hobj = 0;
+    H5Group * group = 0;
+    SciErr err;
+    int * addr = 0;
+    char * name = 0;
+    std::string _name;
+
+    CheckLhs(1, 1);
+    CheckRhs(2, 2);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
+    {
+        hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!hobj)
+        {
+            Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A H5Object expected.\n"), fname, 1);
+    }
+
+    err = getVarAddressFromPosition(pvApiCtx, 2, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+        return 0;
+    }
+
+    if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+    {
+        Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 2);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, addr, &name) != 0)
+    {
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+    _name = std::string(name);
+    freeAllocatedSingleString(name);
+
+    try
+    {
+        group = &H5Group::createGroup(*hobj, _name);
+        group->createOnScilabStack(Rhs + 1, pvApiCtx);
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        return 0;
+    }
+
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5link.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5link.cpp
new file mode 100644 (file)
index 0000000..806c647
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include <string>
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+}
+
+#include "HDF5Scilab.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5link(char *fname, unsigned long fname_len)
+{
+    H5Object * hobj = 0;
+    H5Object * target = 0;
+    SciErr err;
+    int * addr = 0;
+    char * name = 0;
+    char * targetName = 0;
+    char * targetFile = 0;
+    std::string _name;
+    std::string _targetName;
+    std::string _targetFile;
+    int _hard = 0;
+    bool hard = false;
+
+    CheckLhs(1, 1);
+    CheckRhs(3, 4);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
+    {
+        hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!hobj)
+        {
+            Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A H5Object expected.\n"), fname, 1);
+    }
+
+    err = getVarAddressFromPosition(pvApiCtx, 2, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+        return 0;
+    }
+
+    if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+    {
+        Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 2);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, addr, &name) != 0)
+    {
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+    _name = std::string(name);
+    freeAllocatedSingleString(name);
+
+    err = getVarAddressFromPosition(pvApiCtx, 3, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
+        return 0;
+    }
+
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
+    {
+        target = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!target)
+        {
+            Scierror(999, _("%s: Can not use H5Object: invalid object.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 3);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &targetName) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+
+        _targetName = std::string(targetName);
+        freeAllocatedSingleString(targetName);
+    }
+
+    if (Rhs == 4)
+    {
+        err = getVarAddressFromPosition(pvApiCtx, 4, &addr);
+        if (err.iErr)
+        {
+            printError(&err, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 4);
+            return 0;
+        }
+
+        if (!checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, _("%s: Wrong size for input argument #%d.\n"), fname, 4);
+            return 0;
+        }
+
+        if (isBooleanType(pvApiCtx, addr))
+        {
+            if (getScalarBoolean(pvApiCtx, addr, &_hard) != 0)
+            {
+                Scierror(999, _("%s: No more memory.\n"), fname);
+                return 0;
+            }
+
+            hard = _hard != 0;
+        }
+        else if (isStringType(pvApiCtx, addr) && !_targetName.empty())
+        {
+            if (getAllocatedSingleString(pvApiCtx, addr, &targetFile) != 0)
+            {
+                Scierror(999, _("%s: No more memory.\n"), fname);
+                return 0;
+            }
+
+            _targetFile = std::string(targetFile);
+            freeAllocatedSingleString(targetFile);
+        }
+        else
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A string or a boolean expected.\n"), fname);
+            return 0;
+        }
+    }
+
+    try
+    {
+        if (target)
+        {
+            HDF5Scilab::createLink(*hobj, _name, *target, hard);
+        }
+        else
+        {
+            if (_targetFile.empty())
+            {
+                HDF5Scilab::createLink(*hobj, _name, _targetName, hard);
+            }
+            else
+            {
+                HDF5Scilab::createLink(*hobj, _name, _targetName, _targetFile);
+            }
+        }
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        return 0;
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5ls.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5ls.cpp
new file mode 100644 (file)
index 0000000..f4b8eac
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include <string>
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "expandPathVariable.h"
+}
+
+#include "HDF5Scilab.hxx"
+#include "H5File.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5ls(char *fname, unsigned long fname_len)
+{
+    H5Object * hobj = 0;
+    SciErr err;
+    int * addr = 0;
+    char * path = 0;
+    char * expandedPath = 0;
+    char * name = 0;
+    bool mustDelete = true;
+
+    CheckLhs(1, 1);
+    CheckRhs(1, 2);
+
+    if (Rhs == 2)
+    {
+        err = getVarAddressFromPosition(pvApiCtx, 2, &addr);
+        if (err.iErr)
+        {
+            printError(&err, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+            return 0;
+        }
+
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 2);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &name) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+    }
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
+    {
+        hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!hobj)
+        {
+            Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+            return 0;
+        }
+        if (Rhs == 2)
+        {
+            try
+            {
+                hobj = &H5Object::getObject(*hobj, name);
+            }
+            catch (H5Exception & e)
+            {
+                Scierror(999, _("%s: %s\n"), fname, e.what());
+                return 0;
+            }
+        }
+        else
+        {
+            mustDelete = false;
+        }
+    }
+    else
+    {
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &path) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+        expandedPath = expandPathVariable(path);
+        freeAllocatedSingleString(path);
+        try
+        {
+            if (Rhs == 2)
+            {
+                hobj = new H5File((const char *)expandedPath, (const char *)name, "r");
+            }
+            else
+            {
+                hobj = new H5File((const char *)expandedPath, "/", "r");
+            }
+            FREE(expandedPath);
+        }
+        catch (const H5Exception & e)
+        {
+            Scierror(999, _("%s: %s\n"), fname, e.what());
+            FREE(expandedPath);
+            return 0;
+        }
+    }
+
+    try
+    {
+        HDF5Scilab::scilabPrint(hobj->ls());
+        if (mustDelete)
+        {
+            delete hobj;
+        }
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        if (mustDelete)
+        {
+            delete hobj;
+        }
+        return 0;
+    }
+
+    LhsVar(1) = 0;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5open.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5open.cpp
new file mode 100644 (file)
index 0000000..3b2faea
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "expandPathVariable.h"
+}
+
+#include "H5File.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5open(char *fname, unsigned long fname_len)
+{
+    H5File * h5file = 0;
+    SciErr err;
+    int * addr = 0;
+    char * path = 0;
+    const char * access = 0;
+    const char * name = 0;
+    char * args[3];
+
+    CheckLhs(1, 1);
+    CheckRhs(1, 3);
+
+    for (int i = 1; i <= Rhs; i++)
+    {
+        err = getVarAddressFromPosition(pvApiCtx, i, &addr);
+        if (err.iErr)
+        {
+            for (int j = 0; j < i; j++)
+            {
+                freeAllocatedSingleString(args[j]);
+            }
+            printError(&err, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, i);
+            return 0;
+        }
+
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            for (int j = 0; j < i; j++)
+            {
+                freeAllocatedSingleString(args[j]);
+            }
+            Scierror(999, gettext("%s: Wrong type for input argument #%d: A string expected.\n"), fname, i);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, args + i - 1) != 0)
+        {
+            for (int j = 0; j < i; j++)
+            {
+                freeAllocatedSingleString(args[j]);
+            }
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+    }
+
+    path = expandPathVariable(args[0]);
+
+    switch (Rhs)
+    {
+        case 1:
+            access = "a";
+            name = "/";
+            break;
+        case 2:
+            if (H5File::checkFileAccess(args[1]))
+            {
+                access = args[1];
+                name = "/";
+            }
+            else
+            {
+                access = "a";
+                name = args[1];
+            }
+            break;
+        case 3:
+            if (H5File::checkFileAccess(args[1]))
+            {
+                access = args[1];
+                name = args[2];
+            }
+            else if (H5File::checkFileAccess(args[2]))
+            {
+                name = args[1];
+                access = args[2];
+            }
+            else
+            {
+                name = args[1];
+                access = "a";
+            }
+    }
+
+    try
+    {
+        h5file = new H5File(path, name, access);
+        for (int i = 0; i < Rhs; i++)
+        {
+            freeAllocatedSingleString(args[i]);
+        }
+        FREE(path);
+    }
+    catch (const H5Exception & e)
+    {
+        for (int i = 0; i < Rhs; i++)
+        {
+            freeAllocatedSingleString(args[i]);
+        }
+        FREE(path);
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        return 0;
+    }
+
+    try
+    {
+        h5file->createOnScilabStack(Rhs + 1, pvApiCtx);
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        delete h5file;
+        return 0;
+    }
+
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5read.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5read.cpp
new file mode 100644 (file)
index 0000000..effb835
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "expandPathVariable.h"
+}
+
+#include "HDF5Scilab.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5read(char *fname, unsigned long fname_len)
+{
+    SciErr err;
+    H5Object * hobj = 0;
+    int * addr = 0;
+    char * path = 0;
+    char * expandedPath = 0;
+    char * location = 0;
+    std::string _expandedPath;
+    std::string _location;
+
+    CheckLhs(1, 1);
+    CheckRhs(1, 2);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
+    {
+        hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!hobj)
+        {
+            Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        if (Rhs != 2)
+        {
+            Scierror(999, _("%s: Invalid number of arguments: %d expected.\n"), fname, 2);
+            return 0;
+        }
+
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &path) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+
+        expandedPath = expandPathVariable(path);
+        _expandedPath = std::string(expandedPath);
+        FREE(expandedPath);
+        freeAllocatedSingleString(path);
+    }
+
+    if (Rhs == 2)
+    {
+        err = getVarAddressFromPosition(pvApiCtx, 2, &addr);
+        if (err.iErr)
+        {
+            printError(&err, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+            return 0;
+        }
+
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &location) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+
+        _location = std::string(location);
+        freeAllocatedSingleString(location);
+    }
+    else
+    {
+        _location = std::string(".");
+    }
+
+    try
+    {
+        if (hobj)
+        {
+            HDF5Scilab::readData(*hobj, _location, Rhs + 1, pvApiCtx);
+        }
+        else
+        {
+            HDF5Scilab::readData(_expandedPath, _location, Rhs + 1, pvApiCtx);
+        }
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        return 0;
+    }
+
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_h5readattr.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_h5readattr.cpp
new file mode 100644 (file)
index 0000000..2e1aa0b
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "localization.h"
+#include "expandPathVariable.h"
+}
+
+#include "HDF5Scilab.hxx"
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_h5readattr(char *fname, unsigned long fname_len)
+{
+    SciErr err;
+    H5Object * hobj = 0;
+    int * addr = 0;
+    char * path = 0;
+    char * name = 0;
+    char * expandedPath = 0;
+    std::string _expandedPath;
+    std::string _location;
+    std::string _name;
+
+    CheckLhs(1, 1);
+    CheckRhs(2, 3);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (HDF5Scilab::isH5Object(addr, pvApiCtx))
+    {
+        hobj = HDF5Scilab::getH5Object(addr, pvApiCtx);
+        if (!hobj)
+        {
+            Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        if (Rhs != 3)
+        {
+            Scierror(999, _("%s: Invalid number of arguments: %d expected.\n"), fname, 3);
+            return 0;
+        }
+
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &path) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+
+        expandedPath = expandPathVariable(path);
+        _expandedPath = std::string(expandedPath);
+        FREE(expandedPath);
+        freeAllocatedSingleString(path);
+    }
+
+    err = getVarAddressFromPosition(pvApiCtx, 2, &addr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+        return 0;
+    }
+
+    if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, addr, &name) != 0)
+    {
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+    if (Rhs == 3)
+    {
+        _location = std::string(name);
+        freeAllocatedSingleString(name);
+
+        err = getVarAddressFromPosition(pvApiCtx, 3, &addr);
+        if (err.iErr)
+        {
+            printError(&err, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 3);
+            return 0;
+        }
+
+        if (!isStringType(pvApiCtx, addr) || !checkVarDimension(pvApiCtx, addr, 1, 1))
+        {
+            Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1);
+            return 0;
+        }
+
+        if (getAllocatedSingleString(pvApiCtx, addr, &name) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        _location = std::string(".");
+    }
+
+    _name = std::string(name);
+    freeAllocatedSingleString(name);
+
+    try
+    {
+        if (hobj)
+        {
+            HDF5Scilab::readAttributeData(*hobj, _location, _name, Rhs + 1, pvApiCtx);
+        }
+        else
+        {
+            HDF5Scilab::readAttributeData(_expandedPath, _location, _name, Rhs + 1, pvApiCtx);
+        }
+    }
+    catch (const H5Exception & e)
+    {
+        Scierror(999, _("%s: %s\n"), fname, e.what());
+        return 0;
+    }
+
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
+
+    return 0;
+}
+
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_e.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_e.cpp
new file mode 100644 (file)
index 0000000..3105ccc
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Exception.hxx"
+#include "HDF5Scilab.hxx"
+#include "H5Object.hxx"
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "sciprint.h"
+#include "localization.h"
+}
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_percent_H5Object_e(char * fname, unsigned long fname_len)
+{
+    H5Object * obj = 0;
+    int id;
+    SciErr err;
+    int * fieldaddr = 0;
+    int * mlistaddr = 0;
+    char * field = 0;
+    int fieldtype;
+    double index;
+
+    CheckLhs(1, 1);
+    CheckRhs(2, 2);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &fieldaddr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        return 0;
+    }
+
+    err = getVarType(pvApiCtx, fieldaddr, &fieldtype);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        return 0;
+    }
+
+    if (fieldtype != sci_matrix && fieldtype != sci_strings)
+    {
+        Scierror(999, gettext("%s: Wrong type for input argument #%i: A string or a double expected.\n"), fname, 1);
+        return 0;
+    }
+
+    err = getVarAddressFromPosition(pvApiCtx, 2, &mlistaddr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+        return 0;
+    }
+
+    if (fieldtype == sci_strings)
+    {
+        if (getAllocatedSingleString(pvApiCtx, fieldaddr, &field) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+    }
+    else
+    {
+        if (getScalarDouble(pvApiCtx, fieldaddr, &index) != 0)
+        {
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
+        }
+    }
+
+    try
+    {
+        id = HDF5Scilab::getH5ObjectId(mlistaddr, pvApiCtx);
+        obj = H5VariableScope::getVariableFromId(id);
+
+        if (fieldtype == sci_strings)
+        {
+            obj->getAccessibleAttribute(std::string(field), Rhs + 1, pvApiCtx);
+        }
+        else
+        {
+            obj->getAccessibleAttribute(index - 1, Rhs + 1, pvApiCtx);
+        }
+    }
+    catch (std::exception & e)
+    {
+        if (fieldtype == sci_strings)
+        {
+            freeAllocatedSingleString(field);
+        }
+        Scierror(999, _("%s: Error in retrieving field content:\n%s\n"), fname, e.what());
+
+        return 0;
+    }
+
+    if (fieldtype == sci_strings)
+    {
+        freeAllocatedSingleString(field);
+    }
+
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
+
+    return 0;
+}
diff --git a/scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_p.cpp b/scilab/modules/hdf5/sci_gateway/cpp/sci_percent_H5Object_p.cpp
new file mode 100644 (file)
index 0000000..2197117
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Exception.hxx"
+#include "HDF5Scilab.hxx"
+#include "H5Object.hxx"
+
+extern "C"
+{
+#include "gw_hdf5.h"
+#include "Scierror.h"
+#include "api_scilab.h"
+#include "sciprint.h"
+#include "localization.h"
+}
+
+using namespace org_modules_hdf5;
+
+/*--------------------------------------------------------------------------*/
+int sci_percent_H5Object_p(char * fname, unsigned long fname_len)
+{
+    H5Object * obj = 0;
+    int id;
+    SciErr err;
+    int * mlistaddr = 0;
+
+    CheckRhs(1, 1);
+
+    err = getVarAddressFromPosition(pvApiCtx, 1, &mlistaddr);
+    if (err.iErr)
+    {
+        printError(&err, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    try
+    {
+        id = HDF5Scilab::getH5ObjectId(mlistaddr, pvApiCtx);
+        obj = H5VariableScope::getVariableFromId(id);
+    }
+    catch (std::exception & e)
+    {
+        Scierror(999, _("%s: Can not print H5Object.\n"), fname);
+        return 0;
+    }
+
+    if (obj)
+    {
+        const std::string str = obj->toString();
+        sciprint("%s\n", str.c_str());
+    }
+    else
+    {
+        Scierror(999, _("%s: Can not print H5Object: invalid object.\n"), fname);
+    }
+
+    return 0;
+}
index 8fe5cd3..1e73e79 100644 (file)
@@ -12,8 +12,8 @@
  -->
 <!DOCTYPE GATEWAY SYSTEM "../../functions/xml/gateway.dtd">
 <GATEWAY name="hdf5">
-
-<!--
+  
+  <!--
  Scilab
  Interface description. In this file, we define the list of the function which
  will be available into Scilab and the link to the "native" function.
  Don't touch if you do not know what you are doing
 
 -->
-<PRIMITIVE gatewayId="62" primitiveId="1" primitiveName="export_to_hdf5" />
-<PRIMITIVE gatewayId="62" primitiveId="2" primitiveName="import_from_hdf5" />
-<PRIMITIVE gatewayId="62" primitiveId="3" primitiveName="listvar_in_hdf5" />
-<PRIMITIVE gatewayId="62" primitiveId="4" primitiveName="is_hdf5_file" />
-<PRIMITIVE gatewayId="62" primitiveId="5" primitiveName="h5dump" />
+  <PRIMITIVE gatewayId="62" primitiveId="1" primitiveName="export_to_hdf5" />
+  <PRIMITIVE gatewayId="62" primitiveId="2" primitiveName="import_from_hdf5" />
+  <PRIMITIVE gatewayId="62" primitiveId="3" primitiveName="listvar_in_hdf5" />
+  <PRIMITIVE gatewayId="62" primitiveId="4" primitiveName="is_hdf5_file" />
+  <PRIMITIVE gatewayId="62" primitiveId="5" primitiveName="h5dump" />
+  <PRIMITIVE gatewayId="62" primitiveId="6" primitiveName="h5open" />
+  <PRIMITIVE gatewayId="62" primitiveId="7" primitiveName="h5close" />
+  <PRIMITIVE gatewayId="62" primitiveId="8" primitiveName="h5read" />
+  <PRIMITIVE gatewayId="62" primitiveId="9" primitiveName="h5ls" />
+  <PRIMITIVE gatewayId="62" primitiveId="10" primitiveName="%H5Object_p" />
+  <PRIMITIVE gatewayId="62" primitiveId="11" primitiveName="%H5Object_e" />
+  <PRIMITIVE gatewayId="62" primitiveId="12" primitiveName="h5group" />
+  <PRIMITIVE gatewayId="62" primitiveId="13" primitiveName="h5delete" />
+  <PRIMITIVE gatewayId="62" primitiveId="14" primitiveName="h5dataset" />
+  <PRIMITIVE gatewayId="62" primitiveId="15" primitiveName="h5attr" />
+  <PRIMITIVE gatewayId="62" primitiveId="16" primitiveName="h5link" />
+  <PRIMITIVE gatewayId="62" primitiveId="17" primitiveName="h5readattr" />
 </GATEWAY>
index cf023b4..91ce7c6 100644 (file)
 namespace org_modules_hdf5
 {
 
-    H5Attribute::H5Attribute(H5Object & _parent, const hid_t parentId, const unsigned int pos) : H5Object(_parent)
+H5Attribute::H5Attribute(H5Object & _parent, const unsigned int pos) : H5Object(_parent), name("")
+{
+    attr = H5Aopen_by_idx(getParent().getH5Id(), ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)pos, H5P_DEFAULT, H5P_DEFAULT);
+    if (attr < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot open attribute at position %u."), pos);
+    }
+
+    ssize_t size = H5Aget_name(attr, 0, 0);
+    if (size > 0)
+    {
+        char * _name = new char[size + 1];
+        H5Aget_name(attr, size + 1, _name);
+        name = std::string(_name);
+        delete[] _name;
+    }
+}
+
+H5Attribute::H5Attribute(H5Object & _parent, const std::string & _name) : H5Object(_parent), name(_name)
+{
+    if (H5Aexists(getParent().getH5Id(), name.c_str()) <= 0)
     {
-        attr = H5Aopen_by_idx(parentId, ".", H5_INDEX_NAME, H5_ITER_NATIVE, (hsize_t)pos, H5P_DEFAULT, H5P_DEFAULT);
-        if (attr < 0)
-        {
-            throw H5Exception(__LINE__, __FILE__, _("Cannot open attribute at position %u."), pos);
-        }
-
-        ssize_t size = H5Aget_name(attr, 0, 0);
-        if (size <= 0)
-        {
-            name = strdup("");
-        }
-        else
-        {
-           char * _name = (char *)MALLOC(sizeof(char) * (size + 1));
-            H5Aget_name(attr, size + 1, _name);
-           name = const_cast<const char *>(_name);
-        }
+        throw H5Exception(__LINE__, __FILE__, _("Cannot open attribute: %s"), name.c_str());
     }
 
-    H5Attribute::~H5Attribute()
+    attr = H5Aopen(getParent().getH5Id(), name.c_str(), H5P_DEFAULT);
+    if (attr < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot open attribute: %s"), name.c_str());
+    }
+}
+
+H5Attribute::H5Attribute(H5Object & _parent, hid_t _attr, const std::string & _name) : H5Object(_parent), attr(_attr), name(_name)
+{
+
+}
+
+H5Attribute::H5Attribute(H5Object & _parent, hid_t _attr, const char * _name) : H5Object(_parent), attr(_attr), name(std::string(_name))
+{
+
+}
+
+H5Attribute::~H5Attribute()
+{
+    if (attr >= 0)
+    {
+        H5Aclose(attr);
+    }
+}
+
+H5Data & H5Attribute::getData()
+{
+    return H5DataFactory::getData(*this, attr, true);
+}
+
+H5Type & H5Attribute::getDataType()
+{
+    hid_t type = H5Aget_type(attr);
+    if (type < 0)
     {
-        if (attr >= 0)
-        {
-            H5Aclose(attr);
-        }
-        FREE(const_cast<char *>(name));
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the attribute type"));
     }
 
-    H5Data & H5Attribute::getData()
+    return *new H5Type(*this, type);
+}
+
+H5Dataspace & H5Attribute::getSpace()
+{
+    hid_t space = H5Aget_space(attr);
+    if (space < 0)
     {
-       return H5DataFactory::getData(*this, attr, true);
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the attribute dataspace"));
     }
 
-    H5Type & H5Attribute::getDataType()
+    return *new H5Dataspace(*this, space);
+}
+
+void H5Attribute::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    SciErr err;
+    std::string lower(_name);
+    std::transform(_name.begin(), _name.end(), lower.begin(), tolower);
+
+    if (lower == "type")
     {
-        hid_t type = H5Aget_type(attr);
-        if (type < 0)
-        {
-            throw H5Exception(__LINE__, __FILE__, _("Cannot get the attribute type"));
-        }
+        const H5Type & type = const_cast<H5Attribute *>(this)->getDataType();
+        type.createOnScilabStack(pos, pvApiCtx);
 
-        return *new H5Type(*this, type);
+        return;
     }
+    else if (lower == "dataspace")
+    {
+        const H5Dataspace & space = const_cast<H5Attribute *>(this)->getSpace();
+        space.createOnScilabStack(pos, pvApiCtx);
 
-    H5Dataspace & H5Attribute::getSpace()
+        return;
+    }
+    else if (lower == "data")
     {
-        hid_t space = H5Aget_space(attr);
-        if (space < 0)
-        {
-            throw H5Exception(__LINE__, __FILE__, _("Cannot get the attribute dataspace"));
-        }
+        const H5Data & data = const_cast<H5Attribute *>(this)->getData();
+        data.toScilab(pvApiCtx, pos);
+
+        delete &data;
 
-        return *new H5Dataspace(*this, space);
+        return;
     }
 
-    std::string H5Attribute::dump(const unsigned int indentLevel) const
+    H5Object::getAccessibleAttribute(_name, pos, pvApiCtx);
+}
+
+std::string H5Attribute::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    const H5Type & type = const_cast<H5Attribute *>(this)->getDataType();
+    const H5Dataspace & space = const_cast<H5Attribute *>(this)->getSpace();
+    const H5Data & data = const_cast<H5Attribute *>(this)->getData();
+
+    os << H5Object::getIndentString(indentLevel) << "ATTRIBUTE \"" << getName() << "\" {" << std::endl
+       << type.dump(alreadyVisited, indentLevel + 1)
+       << space.dump(alreadyVisited, indentLevel + 1)
+       << data.dump(alreadyVisited, indentLevel + 1)
+       << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+    delete &type;
+    delete &space;
+    delete &data;
+
+    return os.str();
+}
+
+std::string H5Attribute::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    const std::string indentString = H5Object::getIndentString(indentLevel + 1);
+    const H5Type & type = const_cast<H5Attribute *>(this)->getDataType();
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 Attribute" << std::endl
+       << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+       << indentString << _("Attribute name") << ": " << getName() << std::endl
+       << indentString << _("Attribute path") << ": " << getCompletePath() << std::endl
+       << indentString << _("Value class") << ": " << type.getClassName();
+
+    delete &type;
+
+    return os.str();
+}
+
+hid_t H5Attribute::create(H5Object & loc, const std::string & name, hid_t type, hid_t targettype, hid_t space, void * data)
+{
+    herr_t err;
+    hid_t attr = H5Acreate2(loc.getH5Id(), name.c_str(), targettype, space, H5P_DEFAULT, H5P_DEFAULT);
+    if (attr < 0)
     {
-       std::ostringstream os;
-       const H5Type & type = const_cast<H5Attribute *>(this)->getDataType();
-       const H5Dataspace & space = const_cast<H5Attribute *>(this)->getSpace();
-       const H5Data & data = const_cast<H5Attribute *>(this)->getData();
-
-       os << H5Object::getIndentString(indentLevel) << "ATTRIBUTE \"" << name << "\" {" << std::endl
-          << type.dump(indentLevel + 1)
-          << space.dump(indentLevel + 1)
-          << data.dump(indentLevel + 1)
-          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
-
-       delete &type;
-       delete &space;
-       delete &data;
-
-       return os.str();
+        throw H5Exception(__LINE__, __FILE__, _("Cannot create a new attribute."));
     }
 
-    std::string H5Attribute::toString(const unsigned int indentLevel) const
+    err = H5Awrite(attr, type, data);
+    if (err < 0)
     {
-       std::ostringstream os;
-       const std::string indentString = H5Object::getIndentString(indentLevel);
-       const H5Type & type = const_cast<H5Attribute *>(this)->getDataType();
-       
-       os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
-          << indentString << _("Attribute name") << ": " << name << std::endl
-          << indentString << _("Attribute path") << ": " << getCompletePath() << std::endl
-          << indentString << _("Value class") << ": " << type.getClassName();
-
-       delete &type;
-
-       return os.str();
+        H5Dclose(attr);
+        throw H5Exception(__LINE__, __FILE__, _("Cannot write data in the attribute."));
     }
+
+    return attr;
+}
 }
index 543213e..bf5584b 100644 (file)
 
 namespace org_modules_hdf5
 {
-    class H5Attribute : protected H5Object
+class H5Attribute : public H5Object
+{
+    hid_t attr;
+    std::string name;
+
+public :
+
+    H5Attribute(H5Object & _parent, const unsigned int pos);
+    H5Attribute(H5Object & _parent, const std::string & name);
+    H5Attribute(H5Object & _parent, hid_t _attr, const char * _name);
+    H5Attribute(H5Object & _parent, hid_t _attr, const std::string & _name);
+
+    ~H5Attribute();
+
+    hid_t getH5Id() const
     {
-       hid_t attr;
-       const char * name;
-
-    public :
-       
-       H5Attribute(H5Object & _parent, const hid_t parentId, const unsigned int pos);
-       
-       ~H5Attribute();
-
-       hid_t getH5Id() const { return attr; }
-       virtual std::string getName() const { return std::string(name); }
-       H5Data & getData();
-       H5Type & getDataType();
-       H5Dataspace & getSpace();
-
-       virtual std::string dump(const unsigned int indentLevel) const; 
-       virtual std::string toString(const unsigned int indentLevel) const; 
-    };
+        return attr;
+    }
+
+    virtual const std::string & getName() const
+    {
+        return name;
+    }
+
+    H5Data & getData();
+    H5Type & getDataType();
+    H5Dataspace & getSpace();
+    virtual void getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const;
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+    virtual std::string toString(const unsigned int indentLevel) const;
+
+    static hid_t create(H5Object & loc, const std::string & name, hid_t type, hid_t targettype, hid_t space, void * data);
+};
 }
 
 #endif // __H5ATTRIBUTE_HXX__
index 98474af..6d5bd43 100644 (file)
 
 namespace org_modules_hdf5
 {
-    
-    H5AttributesList::H5AttributesList(H5Object & _parent) : H5ListObject(_parent) { }
 
-    H5AttributesList::~H5AttributesList() { }
+H5AttributesList::H5AttributesList(H5Object & _parent) : H5ListObject(_parent) { }
 
-    const unsigned int H5AttributesList::getSize() const
-    {
-       H5O_info_t info;
-       herr_t err = H5Oget_info(parent.getH5Id(), &info);
-       
-       if (err < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot get the size of attribute list."));
-       }
-       
-       return (unsigned int)info.num_attrs;
-    }
+H5AttributesList::~H5AttributesList() { }
 
-    void H5AttributesList::setObject(const unsigned int pos, H5Attribute & attribute)
-    {
-       
-    }
+const unsigned int H5AttributesList::getSize() const
+{
+    H5O_info_t info;
+    herr_t err = H5Oget_info(parent.getH5Id(), &info);
 
-    H5Attribute & H5AttributesList::getObject(const int pos)
+    if (err < 0)
     {
-       return getObject(pos, true);
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the size of attribute list."));
     }
 
-    H5Attribute & H5AttributesList::getObject(const int pos, const bool checkPos)
-    {
-       if (checkPos)
-       {
-           unsigned int size = getSize();
-           if (pos < 0 || pos >= size)
-           {
-               throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
-           }
-       }
-
-       return *new H5Attribute(parent, parent.getH5Id(), (const unsigned int)pos);
-    }
+    return (unsigned int)info.num_attrs;
+}
+
+void H5AttributesList::setObject(const unsigned int pos, H5Attribute & attribute)
+{
+
+}
+
+H5Attribute & H5AttributesList::getObject(const std::string & name)
+{
+    return *new H5Attribute(parent, name);
+}
 
-    std::string H5AttributesList::dump(const unsigned int indentLevel) const
+H5Attribute & H5AttributesList::getObject(const int pos)
+{
+    return getObject(pos, true);
+}
+
+H5Attribute & H5AttributesList::getObject(const int pos, const bool checkPos)
+{
+    if (checkPos)
     {
-       std::ostringstream os;
-       unsigned int size = getSize();
-       
-       for (unsigned int i = 0; i < size; i++)
-       {
-           const H5Attribute & attr = const_cast<H5AttributesList *>(this)->getObject(i, false);
-           os << attr.dump(indentLevel);
-
-           delete &attr;
-       }
-       
-       return os.str();
+        unsigned int size = getSize();
+        if (pos < 0 || pos >= size)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
+        }
     }
 
-    std::string H5AttributesList::toString(const unsigned int indentLevel) const
+    return *new H5Attribute(parent, (const unsigned int)pos);
+}
+
+std::string H5AttributesList::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    unsigned int size = getSize();
+
+    for (unsigned int i = 0; i < size; i++)
     {
-       std::ostringstream os;
-       std::string indentString = H5Object::getIndentString(indentLevel);
-       
-       os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
-          << indentString << _("Number of attributes") << ": " << getSize();
+        const H5Attribute & attr = const_cast<H5AttributesList *>(this)->getObject(i, false);
+        os << attr.dump(alreadyVisited, indentLevel);
 
-       return os.str();
+        delete &attr;
     }
+
+    return os.str();
+}
+
+std::string H5AttributesList::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel);
+
+    os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+       << indentString << _("Attributes") << ": [1 x " << getSize() << "]";
+
+    return os.str();
+}
 }
index 3a505e0..191e100 100644 (file)
 
 namespace org_modules_hdf5
 {
-    class H5Attribute;
-
-    class H5AttributesList : protected H5ListObject<H5Attribute>
-    {
-
-    public :
-       
-       H5AttributesList(H5Object & _parent);
-       
-       ~H5AttributesList();
-
-       void setObject(const unsigned int pos, H5Attribute & attribute);
-       H5Attribute & getObject(const int pos);
-       const unsigned int getSize() const;
-       
-       virtual std::string dump(const unsigned int indentLevel) const;
-        virtual std::string toString(const unsigned int indentLevel) const;
-
-    private:
-       H5Attribute & getObject(const int pos, const bool checkPos);
-    };
+class H5Attribute;
+
+class H5AttributesList : public H5ListObject<H5Attribute>
+{
+
+public :
+
+    H5AttributesList(H5Object & _parent);
+
+    ~H5AttributesList();
+
+    virtual void setObject(const unsigned int pos, H5Attribute & attribute);
+    virtual H5Attribute & getObject(const int pos);
+    virtual H5Attribute & getObject(const std::string & name);
+    virtual const unsigned int getSize() const;
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+    virtual std::string toString(const unsigned int indentLevel) const;
+
+private:
+    H5Attribute & getObject(const int pos, const bool checkPos);
+};
 }
 
 #endif // __H5ATTRIBUTESLIST_HXX__
index 5a165b6..ab9bf3d 100644 (file)
@@ -29,7 +29,7 @@
             err = createMatrixOf##NAME(pvApiCtx, position, rows, cols, ptr); \
         }                                                               \
         if (err.iErr)                                                   \
-        {                                                               \
+        {           printError(&err, 0);                               \
             throw H5Exception(__LINE__, __FILE__, "Cannot allocate memory"); \
         }                                                               \
     }
@@ -46,7 +46,7 @@
             err = allocMatrixOf##NAME(pvApiCtx, position, rows, cols, ptr); \
         }                                                               \
         if (err.iErr)                                                   \
-        {                                                               \
+        {           printError(&err, 0);                                                            \
             throw H5Exception(__LINE__, __FILE__, "Cannot allocate memory"); \
         }                                                               \
     }
 
 namespace org_modules_hdf5
 {
-    template<typename T>
-    class H5BasicData : public H5Data
+template<typename T>
+class H5BasicData : public H5Data
+{
+
+protected:
+
+    T * transformedData;
+
+public:
+
+    H5BasicData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, T * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, static_cast<void *>(_data), _stride, _offset, _dataOwner), transformedData(0)
     {
 
-    protected:
+    }
 
-        T * transformedData;
+    virtual ~H5BasicData()
+    {
+        if (transformedData)
+        {
+            delete[] transformedData;
+        }
+    }
 
-    public:
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+    {
+        os << static_cast<T *>(getData())[pos];
+    }
 
-        H5BasicData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, T * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, static_cast<void *>(_data), _stride, _offset, _dataOwner), transformedData(0)
+    virtual void copyData(T * dest) const
+    {
+        if (dest)
+        {
+            if (stride == -1)
             {
-
+                memcpy(static_cast<void *>(dest), data, totalSize * sizeof(T));
             }
-
-        virtual ~H5BasicData()
+            else if (transformedData)
             {
-                if (transformedData)
-                {
-                    delete[] transformedData;
-                }
+                memcpy(static_cast<void *>(dest), static_cast<void *>(transformedData), totalSize * sizeof(T));
             }
-
-
-
-        virtual void copyData(T * dest) const
+            else
             {
-                if (dest)
+                char * cdata = static_cast<char *>(data) + offset;
+                for (int i = 0; i < totalSize; i++)
                 {
-                    if (stride == -1)
-                    {
-                        memcpy(static_cast<void *>(dest), data, totalSize * sizeof(T));
-                    }
-                    else if (transformedData)
-                    {
-                        memcpy(static_cast<void *>(dest), static_cast<void *>(transformedData), totalSize * sizeof(T));
-                    }
-                    else
-                    {
-                        char * cdata = static_cast<char *>(data) + offset;
-                        for (int i = 0; i < totalSize; i++)
-                        {
-                            dest[i] = *((T *)cdata);
-                            cdata += stride;
-                        }
-                    }
-                }
-                else
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot copy data to an empty pointer"));
+                    dest[i] = *((T *)cdata);
+                    cdata += stride;
                 }
             }
+        }
+        else
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot copy data to an empty pointer"));
+        }
+    }
 
-        virtual void * getData() const
+    virtual void * getData() const
+    {
+        if (stride == -1)
+        {
+            return data;
+        }
+        else
+        {
+            if (!transformedData)
             {
-                if (stride == -1)
-                {
-                    return data;
-                }
-                else
-                {
-                    if (!transformedData)
-                    {
-                        const_cast<H5BasicData *>(this)->transformedData = new T[totalSize];
-                        copyData(transformedData);
-                    }
-
-                    return static_cast<void *>(transformedData);
-                }
+                T * dest = new T[totalSize];
+                copyData(dest);
+                const_cast<H5BasicData *>(this)->transformedData = dest;
             }
 
-        virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+            return static_cast<void *>(transformedData);
+        }
+    }
+
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+    {
+        SciErr err;
+        T * newData = 0;
+        if (ndims == 1)
+        {
+            alloc(pvApiCtx, lhsPosition, 1, *dims, parentList, listPosition, &newData);
+            copyData(newData);
+        }
+        else
+        {
+            if (ndims == 2)
             {
-                SciErr err;
-                T * newData = 0;
-                if (ndims == 1)
-                {
-                    alloc(pvApiCtx, lhsPosition, 1, *dims, parentList, listPosition, &newData);
-                    copyData(newData);
-                }
-                else
-                {
-                    if (ndims == 2)
-                    {
-                        alloc(pvApiCtx, lhsPosition, dims[0], dims[1], parentList, listPosition, &newData);
-                        H5DataConverter::C2FHypermatrix(2, dims, 0, static_cast<T *>(getData()), newData);
-                    }
-                    else
-                    {
-                        int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
-                       alloc(pvApiCtx, lhsPosition, 1, totalSize, list, 3, &newData);
-                        H5DataConverter::C2FHypermatrix(ndims, dims, totalSize, static_cast<T *>(getData()), newData);
-                    }
-                }
+                alloc(pvApiCtx, lhsPosition, dims[0], dims[1], parentList, listPosition, &newData);
+                H5DataConverter::C2FHypermatrix(2, dims, 0, static_cast<T *>(getData()), newData);
             }
-
-        virtual std::string dump(const unsigned int indentLevel) const
+            else
             {
-                return H5DataConverter::dump(indentLevel, ndims, dims, static_cast<T *>(getData()), *this);
+                int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
+                alloc(pvApiCtx, lhsPosition, 1, totalSize, list, 3, &newData);
+                H5DataConverter::C2FHypermatrix(ndims, dims, totalSize, static_cast<T *>(getData()), newData);
             }
+        }
+    }
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+    {
+        return H5DataConverter::dump(alreadyVisited, indentLevel, ndims, dims, *this);
+    }
 
-        __SCILAB_ALLOCATORS_CREATORS__(double,Double)
-        __SCILAB_ALLOCATORS_CREATORS__(char,Integer8)
-        __SCILAB_ALLOCATORS_CREATORS__(unsigned char,UnsignedInteger8)
-        __SCILAB_ALLOCATORS_CREATORS__(short,Integer16)
-        __SCILAB_ALLOCATORS_CREATORS__(unsigned short,UnsignedInteger16)
-        __SCILAB_ALLOCATORS_CREATORS__(int,Integer32)
-        __SCILAB_ALLOCATORS_CREATORS__(unsigned int,UnsignedInteger32)
+    __SCILAB_ALLOCATORS_CREATORS__(double, Double)
+    __SCILAB_ALLOCATORS_CREATORS__(char, Integer8)
+    __SCILAB_ALLOCATORS_CREATORS__(unsigned char, UnsignedInteger8)
+    __SCILAB_ALLOCATORS_CREATORS__(short, Integer16)
+    __SCILAB_ALLOCATORS_CREATORS__(unsigned short, UnsignedInteger16)
+    __SCILAB_ALLOCATORS_CREATORS__(int, Integer32)
+    __SCILAB_ALLOCATORS_CREATORS__(unsigned int, UnsignedInteger32)
 
 #ifdef  _SCILAB_INT64__
-        __SCILAB_ALLOCATORS_CREATORS__(long long,Integer64)
-        __SCILAB_ALLOCATORS_CREATORS__(unsigned long long,UnsignedInteger64)
+    __SCILAB_ALLOCATORS_CREATORS__(long long, Integer64)
+    __SCILAB_ALLOCATORS_CREATORS__(unsigned long long, UnsignedInteger64)
 #endif
 
-        __SCILAB_STACK_CREATOR__(char *,String)
-    };
+    __SCILAB_STACK_CREATOR__(char *, String)
+};
 }
 
 
index cb411d4..3b6f5b0 100644 (file)
 namespace org_modules_hdf5
 {
 
-    class H5BitfieldData : public H5BasicData<char>
+class H5BitfieldData : public H5BasicData<char>
+{
+
+public:
+
+    H5BitfieldData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims + 1, _dims, _data, _stride, _offset, _dataOwner)
     {
-       
-    public:
-       
-       H5BitfieldData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims + 1, _dims, _data, _stride, _offset, _dataOwner)
-           {
-               //dims[ndims - 1] = dataSize;
-           }
-
-       virtual ~H5BitfieldData()
-           {
-           }
-    };
+        //dims[ndims - 1] = dataSize;
+    }
+
+    virtual ~H5BitfieldData()
+    {
+
+    }
+};
 }
 
 #endif // __H5BITFIELDDATA_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5CharData.hxx b/scilab/modules/hdf5/src/cpp/H5CharData.hxx
new file mode 100644 (file)
index 0000000..deb51c8
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5CHARDATA_HXX__
+#define __H5CHARDATA_HXX__
+
+#include "H5Data.hxx"
+
+namespace org_modules_hdf5
+{
+
+class H5CharData : public H5BasicData<char>
+{
+
+public:
+
+    H5CharData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
+    {
+
+    }
+
+    virtual ~H5CharData()
+    {
+
+    }
+
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+    {
+        os << (int)static_cast<char *>(getData())[pos];
+    }
+};
+}
+
+#endif // __H5CHARDATA_HXX__
index 7f08381..c5a6ca2 100644 (file)
 #define __H5COMPOUNDDATA_HXX__
 
 #include "H5Data.hxx"
+#include "H5BasicData.hxx"
 
 namespace org_modules_hdf5
 {
 
-    class H5CompoundData : public H5BasicData<char>
+class H5CompoundData : public H5BasicData<char>
+{
+    const unsigned int nfields;
+    const std::string * fieldsname;
+    H5Data ** fieldsvalue;
+
+public:
+
+    H5CompoundData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const unsigned int _nfields, std::string * _fieldsname, H5Data ** _fieldsvalue, char * _data, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _data, -1, 0, _dataOwner), nfields(_nfields), fieldsname(_fieldsname), fieldsvalue(_fieldsvalue)
+    {
+
+    }
+
+    virtual ~H5CompoundData()
+    {
+        delete[] fieldsname;
+        delete[] fieldsvalue;
+    }
+
+    H5Data & getData(const std::string fieldname) const
+    {
+        for (unsigned int i = 0; i < nfields; i++)
+        {
+            if (fieldname == fieldsname[i])
+            {
+                return *fieldsvalue[i];
+            }
+        }
+
+        throw H5Exception(__LINE__, __FILE__, _("Invalid field name: %s"), fieldname.c_str());
+    }
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
     {
-       const unsigned int nfields;
-       const std::string * fieldsname;
-       H5Data ** fieldsvalue;
-       
-    public:
-       
-       H5CompoundData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, const unsigned int _nfields, std::string * _fieldsname, H5Data ** _fieldsvalue, char * _data, const bool _dataOwner) : H5BasicData(_parent, _totalSize, _dataSize, _ndims, _dims, _data, -1, 0, _dataOwner), nfields(_nfields), fieldsname(_fieldsname), fieldsvalue(_fieldsvalue)  
-           {
-
-           }
-
-       virtual ~H5CompoundData()
-           {
-               delete[] fieldsname;
-               delete[] fieldsvalue;
-           }
-
-       H5Data & getData(const std::string fieldname)
-           {
-               for (unsigned int i = 0; i < nfields; i++)
-               {
-                   if (fieldname == fieldsname[i])
-                   {
-                       return *fieldsvalue[i];
-                   }
-               }
-
-               throw H5Exception(__LINE__, __FILE__, _("Invalid field name: %s"), fieldname.c_str());
-           }
-
-       virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
-           {
-               static int structdims[2] = { 1, 1 };
-               const char ** _fieldsname = new const char *[nfields + 2];
-               SciErr err;
-               int * scilabStruct = 0;
-
-               _fieldsname[0] = "st";
-               _fieldsname[1] = "dims";
-               for (int i = 0; i < nfields; i++)
-               {
-                   _fieldsname[i + 2] = fieldsname[i].c_str();
-               }
-               
-                
-               if (parentList)
-                {
-                    err = createMListInList(pvApiCtx, lhsPosition, parentList, listPosition, nfields + 1, &scilabStruct);
-                }
-                else
-                {
-                    err = createMList(pvApiCtx, lhsPosition, nfields + 1, &scilabStruct);
-                }
-
-                if (err.iErr)
-                {
-                   delete[] _fieldsname;
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
-                }
-
-                err = createMatrixOfStringInList(pvApiCtx, lhsPosition, scilabStruct, 1, 1, nfields + 2, _fieldsname);
-               delete[] _fieldsname;
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
-                }
-
-                err = createMatrixOfInteger32InList(pvApiCtx, lhsPosition, scilabStruct, 2, 1, 2, structdims);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
-                }
-
-               for (int i = 0; i < nfields; i++)
-               {
-                   fieldsvalue[i]->toScilab(pvApiCtx, lhsPosition, scilabStruct, i + 3);
-               }
-           }
-    };
+        return H5DataConverter::dump(alreadyVisited, indentLevel, ndims, dims, *this, false);
+    }
+
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+    {
+        os << "{" << std::endl;
+        std::string indent = H5Object::getIndentString(indentLevel + 2);
+        for (unsigned int i = 0; i < nfields - 1; i++)
+        {
+            os << indent;
+            fieldsvalue[i]->printData(os, pos, indentLevel + 2);
+            os << ", " << std::endl;
+        }
+        os << indent;
+        fieldsvalue[nfields - 1]->printData(os, pos, indentLevel + 2);
+        os << std::endl << H5Object::getIndentString(indentLevel + 1) << "}";
+    }
+
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+    {
+        static int structdims[2] = { 1, 1 };
+        const char ** _fieldsname = new const char *[nfields + 2];
+        SciErr err;
+        int * scilabStruct = 0;
+
+        _fieldsname[0] = "st";
+        _fieldsname[1] = "dims";
+        for (int i = 0; i < nfields; i++)
+        {
+            _fieldsname[i + 2] = fieldsname[i].c_str();
+        }
+
+        if (parentList)
+        {
+            err = createMListInList(pvApiCtx, lhsPosition, parentList, listPosition, nfields + 1, &scilabStruct);
+        }
+        else
+        {
+            err = createMList(pvApiCtx, lhsPosition, nfields + 2, &scilabStruct);
+        }
+
+        if (err.iErr)
+        {
+            delete[] _fieldsname;
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
+        }
+
+        err = createMatrixOfStringInList(pvApiCtx, lhsPosition, scilabStruct, 1, 1, nfields + 2, _fieldsname);
+        delete[] _fieldsname;
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
+        }
+
+        err = createMatrixOfInteger32InList(pvApiCtx, lhsPosition, scilabStruct, 2, 1, 2, structdims);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a struct on the stack"));
+        }
+
+        for (int i = 0; i < nfields; i++)
+        {
+            fieldsvalue[i]->toScilab(pvApiCtx, lhsPosition, scilabStruct, i + 3);
+        }
+    }
+};
 }
 
 #endif // __H5COMPOUNDDATA_HXX__
index 2a7205c..727fa62 100644 (file)
 
 namespace org_modules_hdf5
 {
-    class H5Data : public H5Object
-    {
-
-    protected:
+class H5Data : public H5Object
+{
 
-        void * data;
-        const hsize_t totalSize;
-        const hsize_t dataSize;
-        const hsize_t ndims;
-        const hsize_t * dims;
-        const hsize_t stride;
-        const size_t offset;
-        const bool dataOwner;
+protected:
 
-    public:
+    void * data;
+    const hsize_t totalSize;
+    const hsize_t dataSize;
+    const hsize_t ndims;
+    const hsize_t * dims;
+    const hsize_t stride;
+    const size_t offset;
+    const bool dataOwner;
 
-        H5Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, void * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Object(_parent), totalSize(_totalSize), dataSize(_dataSize), ndims(_ndims), dims(_dims), data(_data), stride(_stride), offset(_offset), dataOwner(_dataOwner)
-            {
+public:
 
-            }
+    H5Data(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, void * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Object(_parent), totalSize(_totalSize), dataSize(_dataSize), ndims(_ndims), dims(_dims), data(_data), stride(_stride), offset(_offset), dataOwner(_dataOwner)
+    {
 
-        virtual ~H5Data()
-            {
-                if (dataOwner)
-                {
-                    delete[] dims;
-                    FREE(data);
-                }
-            }
+    }
 
-        virtual void * getData() const { return data; }
+    virtual ~H5Data()
+    {
+        if (dataOwner)
+        {
+            delete[] dims;
+            delete[] static_cast<char *>(data);
+        }
+    }
+
+    virtual void * getData() const
+    {
+        return data;
+    }
 
-       virtual void printData(std::ostream & os, void * data) const { }
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const {  }
 
-        virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const = 0;
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const = 0;
 
-    protected:
+protected:
 
-        int * getHypermatrix(void * pvApiCtx, const int position, int * parentList = 0, const int listPosition = 0) const
+    int * getHypermatrix(void * pvApiCtx, const int position, int * parentList = 0, const int listPosition = 0) const
+    {
+        static const char * hypermat[3] = {"hm", "dims", "entries"};
+
+        int * list = 0;
+        SciErr err;
+        if (parentList)
+        {
+            err = createMListInList(pvApiCtx, position, parentList, listPosition, 3, &list);
+        }
+        else
+        {
+            err = createMList(pvApiCtx, position, 3, &list);
+        }
+
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+        }
+
+        err = createMatrixOfStringInList(pvApiCtx, position, list, 1, 1, 3, hypermat);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+        }
+
+        if (sizeof(int) == sizeof(hsize_t))
+        {
+            err = createMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, (int *)dims);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+            }
+        }
+        else
+        {
+            int * _dims = 0;
+            err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, &_dims);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+            }
+            for (int i = 0; i < ndims; i++)
             {
-                static const char * hypermat[3] = {"hm", "dims", "entries"};
-
-                int * list = 0;
-                SciErr err;
-                if (parentList)
-                {
-                    err = createMListInList(pvApiCtx, position, parentList, listPosition, 3, &list);
-                }
-                else
-                {
-                    err = createMList(pvApiCtx, position, 3, &list);
-                }
-
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-
-                err = createMatrixOfStringInList(pvApiCtx, position, list, 1, 1, 3, hypermat);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-
-                if (sizeof(int) == sizeof(hsize_t))
-                {
-                    err = createMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, (int *)dims);
-                    if (err.iErr)
-                    {
-                        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                    }
-                }
-                else
-                {
-                    int * _dims = 0;
-                    err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, &_dims);
-                    if (err.iErr)
-                    {
-                        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                    }
-                    for (int i = 0; i < ndims; i++)
-                    {
-                        _dims[i] = dims[i];
-                    }
-                }
-
-                return list;
+                _dims[i] = dims[i];
             }
-    };
+        }
+
+        return list;
+    }
+};
 }
 
 #endif // __H5DATA_HXX__
index d528c50..2e8407f 100644 (file)
 namespace org_modules_hdf5
 {
 
-    int * H5DataConverter::getHypermatrix(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims)
+int * H5DataConverter::getHypermatrix(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims)
+{
+    static const char * hypermat[3] = {"hm", "dims", "entries"};
+
+    int * list = 0;
+    SciErr err = createMList(pvApiCtx, position, 3, &list);
+    if (err.iErr)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+    }
+
+    err = createMatrixOfStringInList(pvApiCtx, position, list, 1, 1, 3, hypermat);
+    if (err.iErr)
     {
-        static const char * hypermat[3] = {"hm", "dims", "entries"};
+        throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
+    }
 
-        int * list = 0;
-        SciErr err = createMList(pvApiCtx, position, 3, &list);
+    if (sizeof(int) == sizeof(hsize_t))
+    {
+        err = createMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, (int *)dims);
         if (err.iErr)
         {
             throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
         }
-
-        err = createMatrixOfStringInList(pvApiCtx, position, list, 1, 1, 3, hypermat);
+    }
+    else
+    {
+        int * _dims = 0;
+        err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, &_dims);
         if (err.iErr)
         {
             throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
         }
+        for (int i = 0; i < ndims; i++)
+        {
+            _dims[i] = dims[i];
+        }
+    }
 
-       if (sizeof(int) == sizeof(hsize_t))
-       {
-           err = createMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, (int *)dims);
-           if (err.iErr)
-           {
-               throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-           }
-       }
-       else
-       {
-           int * _dims = 0;
-           err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 2, 1, ndims, &_dims);
-           if (err.iErr)
-           {
-               throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-           }
-           for (int i = 0; i < ndims; i++)
-           {
-               _dims[i] = dims[i];
-           }
-       }
+    return list;
+}
 
-        return list;
+void H5DataConverter::toScilabString(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char ** data)
+{
+    SciErr err;
+    if (ndims == 1)
+    {
+        err = createMatrixOfString(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a double matrix on the stack"));
+        }
     }
-
-    void H5DataConverter::toScilabString(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char ** data)
+    else
     {
-       SciErr err;
-        if (ndims == 1)
+        if (ndims == 2)
         {
-            err = createMatrixOfString(pvApiCtx, position, 1, *dims, data);
+            char ** newData = new char*[dims[0] * dims[1]];
+            C2FHypermatrix(2, dims, 0, data, newData);
+            err = createMatrixOfString(pvApiCtx, position, dims[0], dims[1], newData);
+            delete[] newData;
             if (err.iErr)
             {
-                throw H5Exception(__LINE__, __FILE__, _("Cannot create a double matrix on the stack"));
+                throw H5Exception(__LINE__, __FILE__, _("Cannot allocate a double matrix on the stack"));
             }
         }
         else
         {
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                char ** newData = new char*[dims[0] * dims[1]];
-                C2FHypermatrix(2, dims, 0, data, newData);
-                err = createMatrixOfString(pvApiCtx, position, dims[0], dims[1], newData);
-                delete[] newData;
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot allocate a double matrix on the stack"));
-                }
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
-                char ** newData = new char*[size];
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            char ** newData = new char*[size];
+            C2FHypermatrix(ndims, dims, size, data, newData);
 
-                err = createMatrixOfStringInList(pvApiCtx, position, list, 3, 1, (int)size, newData);
-                delete[] newData;
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
+            err = createMatrixOfStringInList(pvApiCtx, position, list, 3, 1, (int)size, newData);
+            delete[] newData;
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
         }
     }
+}
 
-    void H5DataConverter::toScilabDouble(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, double * data)
+void H5DataConverter::toScilabDouble(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, double * data)
+{
+    SciErr err;
+    if (ndims == 1)
+    {
+        err = createMatrixOfDouble(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a double matrix on the stack"));
+        }
+    }
+    else
     {
-       SciErr err;
-        if (ndims == 1)
+        double * newData = 0;
+        if (ndims == 2)
         {
-            err = createMatrixOfDouble(pvApiCtx, position, 1, *dims, data);
+            err = allocMatrixOfDouble(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
-                throw H5Exception(__LINE__, __FILE__, _("Cannot create a double matrix on the stack"));
+                throw H5Exception(__LINE__, __FILE__, _("Cannot allocate a double matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            double * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfDouble(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot allocate a double matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfDoubleInList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfDoubleInList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
-    void H5DataConverter::toScilabInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char * data)
+void H5DataConverter::toScilabInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char * data)
+{
+    SciErr err;
+    if (ndims == 1)
     {
-       SciErr err;
-        if (ndims == 1)
+        err = createMatrixOfInteger8(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
         {
-            err = createMatrixOfInteger8(pvApiCtx, position, 1, *dims, data);
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an int8 matrix on the stack"));
+        }
+    }
+    else
+    {
+        char * newData = 0;
+        if (ndims == 2)
+        {
+
+            err = allocMatrixOfInteger8(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an int8 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            char * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-
-                err = allocMatrixOfInteger8(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int8 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfInteger8InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfInteger8InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
-    void H5DataConverter::toScilabUInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned char * data)
+void H5DataConverter::toScilabUInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned char * data)
+{
+    SciErr err;
+    if (ndims == 1)
+    {
+        err = createMatrixOfUnsignedInteger8(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint8 matrix on the stack"));
+        }
+    }
+    else
     {
-       SciErr err;
-       if (ndims == 1)
+        unsigned char * newData = 0;
+        if (ndims == 2)
         {
-            err = createMatrixOfUnsignedInteger8(pvApiCtx, position, 1, *dims, data);
+            err = allocMatrixOfUnsignedInteger8(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint8 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            unsigned char * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfUnsignedInteger8(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint8 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfUnsignedInteger8InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfUnsignedInteger8InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
-    void H5DataConverter::toScilabInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, short * data)
+void H5DataConverter::toScilabInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, short * data)
+{
+    SciErr err;
+    if (ndims == 1)
+    {
+        err = createMatrixOfInteger16(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an int16 matrix on the stack"));
+        }
+    }
+    else
     {
-       SciErr err;
-        if (ndims == 1)
+        short * newData = 0;
+        if (ndims == 2)
         {
-            err = createMatrixOfInteger16(pvApiCtx, position, 1, *dims, data);
+            err = allocMatrixOfInteger16(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an int16 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            short * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfInteger16(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int16 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfInteger16InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfInteger16InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
-    void H5DataConverter::toScilabUInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned short * data)
+void H5DataConverter::toScilabUInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned short * data)
+{
+    SciErr err;
+    if (ndims == 1)
     {
-       SciErr err;
-        if (ndims == 1)
+        err = createMatrixOfUnsignedInteger16(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
         {
-            err = createMatrixOfUnsignedInteger16(pvApiCtx, position, 1, *dims, data);
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint16 matrix on the stack"));
+        }
+    }
+    else
+    {
+        unsigned short * newData = 0;
+        if (ndims == 2)
+        {
+            err = allocMatrixOfUnsignedInteger16(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint16 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            unsigned short * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfUnsignedInteger16(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint16 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfUnsignedInteger16InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfUnsignedInteger16InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
-    void H5DataConverter::toScilabInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, int * data)
+void H5DataConverter::toScilabInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, int * data)
+{
+    SciErr err;
+    if (ndims == 1)
+    {
+        err = createMatrixOfInteger32(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an int32 matrix on the stack"));
+        }
+    }
+    else
     {
-       SciErr err;
-        if (ndims == 1)
+        int * newData = 0;
+        if (ndims == 2)
         {
-            err = createMatrixOfInteger32(pvApiCtx, position, 1, *dims, data);
+            err = allocMatrixOfInteger32(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an int32 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            int * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfInteger32(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int32 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfInteger32InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
-    void H5DataConverter::toScilabUInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned int * data)
+void H5DataConverter::toScilabUInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned int * data)
+{
+    SciErr err;
+    if (ndims == 1)
     {
-       SciErr err;
-        if (ndims == 1)
+        err = createMatrixOfUnsignedInteger32(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint32 matrix on the stack"));
+        }
+    }
+    else
+    {
+        unsigned int * newData = 0;
+        if (ndims == 2)
         {
-            err = createMatrixOfUnsignedInteger32(pvApiCtx, position, 1, *dims, data);
+            err = allocMatrixOfUnsignedInteger32(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint32 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            unsigned int * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfUnsignedInteger32(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint32 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfUnsignedInteger32InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfUnsignedInteger32InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
 #ifdef __SCILAB_INT64__
 
-    void H5DataConverter::toScilabInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, long long * data)
+void H5DataConverter::toScilabInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, long long * data)
+{
+    SciErr err;
+    if (ndims == 1)
+    {
+        err = createMatrixOfInteger64(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an int64 matrix on the stack"));
+        }
+    }
+    else
     {
-       SciErr err;
-        if (ndims == 1)
+        long long * newData = 0;
+        if (ndims == 2)
         {
-            err = createMatrixOfInteger64(pvApiCtx, position, 1, *dims, data);
+            err = allocMatrixOfInteger64(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an int64 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            long long * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfInteger64(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an int64 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfInteger64InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfInteger64InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
-    void H5DataConverter::toScilabUInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned long long * data)
+void H5DataConverter::toScilabUInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned long long * data)
+{
+    SciErr err;
+    if (ndims == 1)
+    {
+        err = createMatrixOfUnsignedInteger64(pvApiCtx, position, 1, *dims, data);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint64 matrix on the stack"));
+        }
+    }
+    else
     {
-       SciErr err;
-        if (ndims == 1)
+        unsigned long long * newData = 0;
+        if (ndims == 2)
         {
-            err = createMatrixOfUnsignedInteger64(pvApiCtx, position, 1, *dims, data);
+            err = allocMatrixOfUnsignedInteger64(pvApiCtx, position, dims[0], dims[1], &newData);
             if (err.iErr)
             {
                 throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint64 matrix on the stack"));
             }
+            C2FHypermatrix(2, dims, 0, data, newData);
         }
         else
         {
-            unsigned long long * newData = 0;
-            if (ndims == 2)
+            int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
+            hsize_t size = dims[0];
+            for (int i = 1; i < ndims; i++)
             {
-                err = allocMatrixOfUnsignedInteger64(pvApiCtx, position, dims[0], dims[1], &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an uint64 matrix on the stack"));
-                }
-                C2FHypermatrix(2, dims, 0, data, newData);
+                size *= dims[i];
             }
-            else
-            {
-                int * list = getHypermatrix(pvApiCtx, position, ndims, dims);
-                hsize_t size = dims[0];
-                for (int i = 1; i < ndims; i++)
-                {
-                    size *= dims[i];
-                }
 
-                err = allocMatrixOfUnsignedInteger64InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
-                if (err.iErr)
-                {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
-                }
-                C2FHypermatrix(ndims, dims, size, data, newData);
+            err = allocMatrixOfUnsignedInteger64InList(pvApiCtx, position, list, 3, 1, (int)size, &newData);
+            if (err.iErr)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create an hypermatrix on the stack"));
             }
+            C2FHypermatrix(ndims, dims, size, data, newData);
         }
     }
+}
 
 #endif // __SCILAB_INT64__
 
index c7c8cb0..1201c3f 100644 (file)
@@ -28,154 +28,152 @@ extern "C"
 namespace org_modules_hdf5
 {
 
-    class H5DataConverter
-    {
+class H5DataConverter
+{
 
-    public:
+public:
 
-        template <typename T>
-        static std::string dump(const unsigned int indentLevel, const int ndims, const hsize_t * dims, T * data, const H5Data & obj)
-            {
-                std::ostringstream os;
-                std::string indent = H5Object::getIndentString(indentLevel);
+    static std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel, const int ndims, const hsize_t * dims, const H5Data & obj, const bool line = true)
+    {
+        std::ostringstream os;
+        std::string indent = H5Object::getIndentString(indentLevel);
+        unsigned int pos = 0;
 
-                os << indent << "DATA {" << std::endl;
-               printData(indentLevel, indent + "(", os, ndims, dims, &data, obj);
-                os << indent << "}" << std::endl;
+        os << indent << "DATA {" << std::endl;
+        printData(indentLevel, indent + "(", os, ndims, dims, &pos, obj, line);
+        os << indent << "}" << std::endl;
 
-                return os.str();
-            }
+        return os.str();
+    }
 
-        template <typename T>
-        static void printData(const unsigned int indentLevel, const std::string & start, std::ostringstream & os, const int ndims, const hsize_t * dims, T ** data, const H5Data & obj)
+    static void printData(const unsigned int indentLevel, const std::string & start, std::ostringstream & os, const int ndims, const hsize_t * dims, unsigned int * pos, const H5Data & obj, const bool line)
+    {
+        std::string indent = H5Object::getIndentString(indentLevel);
+
+        if (ndims == 0)
+        {
+            os << start << "0): 0";
+        }
+        else if (ndims == 1)
+        {
+            if (line)
             {
-                std::string indent = H5Object::getIndentString(indentLevel);
-
-               if (ndims == 0)
-               {
-                   os << start << "0): 0";
-               }
-                else if (ndims == 1)
+                os << start << "0): ";
+                for (hsize_t i = 0; i < dims[0] - 1; i++)
                 {
-                    os << start << "0): ";
-                    for (hsize_t i = 0; i < dims[0] - 1; i++)
-                    {
-                       printOneData(os, (*data)[i], obj);
-                        os << ", ";
-                    }
-                    printOneData(os, (*data)[dims[0] - 1], obj);
-                    os << std::endl;
-                    *data += dims[0];
-                }
-                else
-                {
-                    std::ostringstream oss;
-                    for (hsize_t i = 0; i < dims[0]; i++)
-                    {
-                        oss << start << (unsigned int)i << ",";
-                        printData(0, oss.str(), os, ndims - 1, dims + 1, data, obj);
-                        oss.str("");
-                    }
+                    obj.printData(os, *pos + i, 0);
+                    os << ", ";
                 }
+                obj.printData(os, *pos + dims[0] - 1, 0);
             }
-
-        template <typename T>
-        static inline void printOneData(std::ostream & os, T data, const H5Data & obj)
+            else
             {
-                os << data;
-            }
-
-        static inline void printOneData(std::ostream & os, char * data, const H5Data & obj)
-            {
-                os << "\"" << data << "\"";
+                for (hsize_t i = 0; i < dims[0] - 1; i++)
+                {
+                    os << start << i << "): ";
+                    obj.printData(os, *pos + i, indentLevel);
+                    os << ", " << std::endl;
+                }
+                os << start << dims[0] - 1 << "): ";
+                obj.printData(os, *pos + dims[0] - 1, indentLevel);
             }
 
-       static inline void printOneData(std::ostream & os, void * data, const H5Data & obj)
+            os << std::endl;
+            *pos += dims[0];
+        }
+        else
+        {
+            std::ostringstream oss;
+            for (hsize_t i = 0; i < dims[0]; i++)
             {
-               obj.printData(os, data);
+                oss << start << (unsigned int)i << ",";
+                printData(indentLevel, oss.str(), os, ndims - 1, dims + 1, pos, obj, line);
+                oss.str("");
             }
+        }
+    }
 
-        static void toScilabString(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char ** data);
+    static void toScilabString(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char ** data);
 
-        static void toScilabDouble(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, double * data);
+    static void toScilabDouble(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, double * data);
 
-        static void toScilabInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char * data);
+    static void toScilabInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, char * data);
 
-        static void toScilabUInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned char * data);
+    static void toScilabUInt8(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned char * data);
 
-        static void toScilabInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, short * data);
+    static void toScilabInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, short * data);
 
-        static void toScilabUInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned short * data);
+    static void toScilabUInt16(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned short * data);
 
-        static void toScilabInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, int * data);
+    static void toScilabInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, int * data);
 
-        static void toScilabUInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned int * data);
+    static void toScilabUInt32(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned int * data);
 
 #ifdef __SCILAB_INT64__
 
-        static void toScilabInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, long long * data);
+    static void toScilabInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, long long * data);
 
-        static void toScilabUInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned long long * data);
+    static void toScilabUInt64(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims, unsigned long long * data);
 
 #endif // __SCILAB_INT64__
 
-        template <typename T>
-        static void C2FHypermatrix(const int ndims, const hsize_t * dims, const hsize_t size, const T * src, T * dest)
+    template <typename T>
+    static void C2FHypermatrix(const int ndims, const hsize_t * dims, const hsize_t size, const T * src, T * dest)
+    {
+        if (ndims == 2)
+        {
+            for (int i = 0; i < dims[0]; i++)
             {
-                if (ndims == 2)
-                {
-                    for (int i = 0; i < dims[0]; i++)
-                    {
-                        for (int j = 0; j < dims[1]; j++)
-                        {
-                            dest[i + dims[0] * j] = src[j + dims[1] * i];
-                        }
-                    }
-                }
-                else
+                for (int j = 0; j < dims[1]; j++)
                 {
-                    hsize_t * cumprod = new hsize_t[ndims];
-                    hsize_t * cumdiv = new hsize_t[ndims];
-                    cumprod[0] = 1;
-                    cumdiv[ndims - 1] = 1;
-                    for (int i = 0; i < ndims - 1; i++)
-                    {
-                        cumprod[i + 1] = dims[i] * cumprod[i];
-                        cumdiv[i] = size / cumprod[i + 1];
-                    }
-
-                    reorder(ndims, dims, cumprod, cumdiv, src, dest);
-                    delete[] cumprod;
-                    delete[] cumdiv;
+                    dest[i + dims[0] * j] = src[j + dims[1] * i];
                 }
             }
+        }
+        else
+        {
+            hsize_t * cumprod = new hsize_t[ndims];
+            hsize_t * cumdiv = new hsize_t[ndims];
+            cumprod[0] = 1;
+            cumdiv[ndims - 1] = 1;
+            for (int i = 0; i < ndims - 1; i++)
+            {
+                cumprod[i + 1] = dims[i] * cumprod[i];
+                cumdiv[i] = size / cumprod[i + 1];
+            }
+
+            reorder(ndims, dims, cumprod, cumdiv, src, dest);
+            delete[] cumprod;
+            delete[] cumdiv;
+        }
+    }
 
-    private:
+private:
 
-        static int * getHypermatrix(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims);
+    static int * getHypermatrix(void * pvApiCtx, const int position, const int ndims, const hsize_t * dims);
 
-        template <typename T>
-        static void reorder(const int ndims, const hsize_t * dims, const hsize_t * cumprod, const hsize_t * cumdiv, const T * src, T * dest)
+    template <typename T>
+    static void reorder(const int ndims, const hsize_t * dims, const hsize_t * cumprod, const hsize_t * cumdiv, const T * src, T * dest)
+    {
+        if (ndims == 1)
+        {
+            for (int i = 0; i < *dims; i++)
             {
-                if (ndims == 1)
-                {
-                    for (int i = 0; i < *dims; i++)
-                    {
-                        *dest = src[i];
-                        dest += *cumprod;
-                    }
-                }
-                else
-                {
-                    for (int i = 0; i < *dims; i++)
-                    {
-                        reorder(ndims - 1, dims + 1, cumprod + 1, cumdiv + 1, src, dest);
-                        dest += *cumprod;
-                        src += *cumdiv;
-                    }
-                }
+                *dest = src[i];
+                dest += *cumprod;
+            }
+        }
+        else
+        {
+            for (int i = 0; i < *dims; i++)
+            {
+                reorder(ndims - 1, dims + 1, cumprod + 1, cumdiv + 1, src, dest);
+                dest += *cumprod;
+                src += *cumdiv;
             }
-    };
+        }
+    }
+};
 }
 
 #endif // __H5DATACONVERTER_HXX__
index 27f328c..ac6bb45 100644 (file)
 
 #include "H5DataFactory.hxx"
 
-#define __SCILAB_HDF5_MAX_DIMS__ 64
-
 namespace org_modules_hdf5
 {
 
-    H5Data & H5DataFactory::getData(H5Object & parent, const hid_t obj, const bool isAttribute)
+H5Data & H5DataFactory::getData(H5Object & parent, const hid_t obj, const bool isAttribute)
+{
+    const hid_t type = isAttribute ? H5Aget_type(obj) : H5Dget_type(obj);
+    if (type < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the data type"));
+    }
+    H5Data * data = 0;
+    // TODO: le type est ferme dans getNativeData: bonne idee ou pas ??
+
+    switch (H5Tget_class(type))
     {
-        const hid_t type = isAttribute ? H5Aget_type(obj) : H5Dget_type(obj);
-       if (type < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot get the data type"));
-       }
-       H5Data * data = 0;
-       // TODO: le type est ferme dans getNativeData: bonne idee ou pas ??
-
-        switch (H5Tget_class(type))
-        {
         case H5T_INTEGER:
             data = &getIntegerData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_FLOAT:
             data = &getFloatingData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_TIME:
             data = &getTimeData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_STRING:
             data = &getStringData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_BITFIELD:
             data = &getBitfieldData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_OPAQUE:
             data = &getOpaqueData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_COMPOUND:
             data = &getCompoundData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_REFERENCE:
             data = &getReferenceData(parent, obj, type, isAttribute);
-           break;
+            break;
         case H5T_ENUM:
             //data = &getEnumData(parent, obj, type, isAttribute);
-           //break;
+            //break;
         case H5T_VLEN:
             //data = &getVlenData(parent, obj, type, isAttribute);
-           //break;
+            //break;
         case H5T_ARRAY:
             //data = &getArrayData(parent, obj, type, isAttribute);
-           //break;
+            //break;
         default:
-           H5Tclose(type);
+            H5Tclose(type);
             throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
-        }
-
-       return *data;
     }
 
-    H5Data & H5DataFactory::getData(H5Object & parent, const hsize_t totalSize, const hid_t type, hsize_t ndims, hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner)
+    return *data;
+}
+
+H5Data & H5DataFactory::getData(H5Object & parent, const hsize_t totalSize, const hid_t type, hsize_t ndims, hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner)
+{
+    hsize_t dataSize = H5Tget_size(type);
+    if (H5Tget_class(type) == H5T_STRING && !H5Tis_variable_str(type))
     {
-       hsize_t dataSize = H5Tget_size(type);
-        if (H5Tget_class(type) == H5T_STRING && !H5Tis_variable_str(type))
-        {
-            // We have a C-string so it is null terminated
-            dataSize++;
-        } 
+        // We have a C-string so it is null terminated
+        dataSize++;
+    }
 
-        switch (H5Tget_class(type))
-        {
+    switch (H5Tget_class(type))
+    {
         case H5T_INTEGER:
             if (H5Tequal(type, H5T_NATIVE_SCHAR))
             {
-                return *new H5BasicData<char>(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
+                return *new H5CharData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
             }
             else if (H5Tequal(type, H5T_NATIVE_UCHAR))
             {
-                return *new H5BasicData<unsigned char>(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data, stride, offset, false);
+                return *new H5UnsignedCharData(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data, stride, offset, false);
             }
             else if (H5Tequal(type, H5T_NATIVE_SHORT))
             {
@@ -111,20 +109,20 @@ namespace org_modules_hdf5
 
             else if (H5Tequal(type, H5T_NATIVE_LONG))
             {
-                return *new H5BasicData(parent, totalSize, dataSize, ndims, dims, (long long *)data, stride, offset, false);
+                return *new H5BasicData<long long>(parent, totalSize, dataSize, ndims, dims, (long long *)data, stride, offset, false);
             }
             else if (H5Tequal(type, H5T_NATIVE_ULONG))
             {
-                return *new H5BasicData(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data, stride, offset, false);
+                return *new H5BasicData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data, stride, offset, false);
             }
 
 #endif // __SCILAB_INT64__
 
-           else
-           {
-               H5Tclose(type);
-               throw H5Exception(__LINE__, __FILE__, _("Unknown integer datatype."));
-           }
+            else
+            {
+                H5Tclose(type);
+                throw H5Exception(__LINE__, __FILE__, _("Unknown integer datatype."));
+            }
             break;
         case H5T_FLOAT:
             if (H5Tequal(type, H5T_NATIVE_FLOAT))
@@ -135,22 +133,22 @@ namespace org_modules_hdf5
             {
                 return *new H5BasicData<double>(parent, totalSize, dataSize, ndims, dims, (double *)data, stride, offset, false);
             }
-           else
-           {
-               throw H5Exception(__LINE__, __FILE__, _("Unknown floating-point datatype."));
-           }
+            else
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Unknown floating-point datatype."));
+            }
             break;
         case H5T_TIME:
             return *new H5TimeData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
         case H5T_STRING:
-           if (H5Tis_variable_str(type))
-           {
-               return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char **)data, stride, offset, false);
-           }
-           else
-           {
-               return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
-           }
+            if (H5Tis_variable_str(type))
+            {
+                return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char **)data, stride, offset, false);
+            }
+            else
+            {
+                return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
+            }
         case H5T_BITFIELD:
             return *new H5BitfieldData(parent, totalSize, dataSize, ndims, dims, (char *)data, stride, offset, false);
         case H5T_OPAQUE:
@@ -175,20 +173,20 @@ namespace org_modules_hdf5
             return *new H5CompoundData(parent, totalSize, dataSize, ndims, dims, nmembers, names, fields, (char *)data, dataOwner);
         }
         case H5T_REFERENCE:
-           // TODO: virer le false
+            // TODO: virer le false
             return *new H5ReferenceData(parent, false, totalSize, dataSize, ndims, dims, (char *)data, offset);
         case H5T_ENUM:
         {
             /*int nmembers = H5Tget_nmembers(type);
-            std::string * names = new std::string[nmembers];
-
-            for (unsigned int i = 0; i < nmembers; i++)
-            {
-                char * mname = H5Tget_member_name(type, i);
-                names[i] = std::string(mname);
-                free(mname);
-            }
-            return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, data, offset, names);*/
+              std::string * names = new std::string[nmembers];
+
+              for (unsigned int i = 0; i < nmembers; i++)
+              {
+              char * mname = H5Tget_member_name(type, i);
+              names[i] = std::string(mname);
+              free(mname);
+              }
+              return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, data, offset, names);*/
         }
         case H5T_VLEN:
             //return *new H5VlenData(parent, totalSize, dataSize, ndims, dims, data, offset);
@@ -196,308 +194,305 @@ namespace org_modules_hdf5
             //return *new H5ArrayData(parent, totalSize, dataSize, ndims, dims, data, offset);
         default:
             throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
-        }
-
-       throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
     }
 
-    H5Data & H5DataFactory::getIntegerData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
-    {
-        hsize_t ndims;
-        hsize_t * dims = 0;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        void * data = 0;
-       H5Data * dataObj = 0;
-       const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+    throw H5Exception(__LINE__, __FILE__, _("Cannot get data from an unknown data type."));
+}
 
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+H5Data & H5DataFactory::getIntegerData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t * dims = 0;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    void * data = 0;
+    H5Data * dataObj = 0;
+    const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
 
-        if (H5Tequal(nativeType, H5T_NATIVE_SCHAR))
-        {
-            dataObj = new H5BasicData<char>(parent, totalSize, dataSize, ndims, dims, (char *)data);
-        }
-        else if (H5Tequal(nativeType, H5T_NATIVE_UCHAR))
-        {
-            dataObj = new H5BasicData<unsigned char>(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data);
-        }
-        else if (H5Tequal(nativeType, H5T_NATIVE_SHORT))
-        {
-            dataObj = new H5BasicData<short>(parent, totalSize, dataSize, ndims, dims, (short *)data);
-        }
-        else if (H5Tequal(nativeType, H5T_NATIVE_USHORT))
-        {
-            dataObj = new H5BasicData<unsigned short>(parent, totalSize, dataSize, ndims, dims, (unsigned short *)data);
-        }
-        else if (H5Tequal(nativeType, H5T_NATIVE_INT))
-        {
-            dataObj = new H5BasicData<int>(parent, totalSize, dataSize, ndims, dims, (int *)data);
-        }
-        else if (H5Tequal(nativeType, H5T_NATIVE_UINT))
-        {
-            dataObj = new H5BasicData<unsigned int>(parent, totalSize, dataSize, ndims, dims, (unsigned int *)data);
-        }
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+    if (H5Tequal(nativeType, H5T_NATIVE_SCHAR))
+    {
+        dataObj = new H5CharData(parent, totalSize, dataSize, ndims, dims, (char *)data);
+    }
+    else if (H5Tequal(nativeType, H5T_NATIVE_UCHAR))
+    {
+        dataObj = new H5UnsignedCharData(parent, totalSize, dataSize, ndims, dims, (unsigned char *)data);
+    }
+    else if (H5Tequal(nativeType, H5T_NATIVE_SHORT))
+    {
+        dataObj = new H5BasicData<short>(parent, totalSize, dataSize, ndims, dims, (short *)data);
+    }
+    else if (H5Tequal(nativeType, H5T_NATIVE_USHORT))
+    {
+        dataObj = new H5BasicData<unsigned short>(parent, totalSize, dataSize, ndims, dims, (unsigned short *)data);
+    }
+    else if (H5Tequal(nativeType, H5T_NATIVE_INT))
+    {
+        dataObj = new H5BasicData<int>(parent, totalSize, dataSize, ndims, dims, (int *)data);
+    }
+    else if (H5Tequal(nativeType, H5T_NATIVE_UINT))
+    {
+        dataObj = new H5BasicData<unsigned int>(parent, totalSize, dataSize, ndims, dims, (unsigned int *)data);
+    }
 
 #ifdef __SCILAB_INT64__
 
-        else if (H5Tequal(nativeType, H5T_NATIVE_LONG))
-        {
-            dataObj = new H5BasicData<long long>(parent, totalSize, dataSize, ndims, dims, (long long *)data);
-        }
-        else if (H5Tequal(nativeType, H5T_NATIVE_ULONG))
-        {
-            dataObj = new H5BasicData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data);
-        }
+    else if (H5Tequal(nativeType, H5T_NATIVE_LONG))
+    {
+        dataObj = new H5BasicData<long long>(parent, totalSize, dataSize, ndims, dims, (long long *)data);
+    }
+    else if (H5Tequal(nativeType, H5T_NATIVE_ULONG))
+    {
+        dataObj = new H5BasicData<unsigned long long>(parent, totalSize, dataSize, ndims, dims, (unsigned long long *)data);
+    }
 
 #endif // __SCILAB_INT64__
-       
-       else
-       {
-           H5Tclose(nativeType);
-           delete[] dims;
-           FREE(data);
-           throw H5Exception(__LINE__, __FILE__, _("Unknown integer datatype."));
-       }
-
-       H5Tclose(nativeType);
-
-       return *dataObj;
-    }
 
-    H5Data & H5DataFactory::getFloatingData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    else
     {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
-       H5Data * dataObj = 0;
-       const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
-
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
-
-       if (H5Tequal(nativeType, H5T_NATIVE_FLOAT))
-       {
-           dataObj = new H5FloatData(parent, totalSize, dataSize, ndims, dims, (float *)data);
-       }
-       else if (H5Tequal(nativeType, H5T_NATIVE_DOUBLE))
-       {
-           dataObj = new H5BasicData<double>(parent, totalSize, dataSize, ndims, dims, (double *)data);
-       }
-       else
-       {
-           H5Tclose(nativeType);
-           delete[] dims;
-           FREE(data);
-           throw H5Exception(__LINE__, __FILE__, _("Unknown floating-point datatype."));
-       }
-
-       H5Tclose(nativeType);
-
-       return *dataObj;
+        H5Tclose(nativeType);
+        delete[] dims;
+        delete[] static_cast<char *>(data);
+        throw H5Exception(__LINE__, __FILE__, _("Unknown integer datatype."));
     }
 
-    H5StringData & H5DataFactory::getStringData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    H5Tclose(nativeType);
+
+    return *dataObj;
+}
+
+H5Data & H5DataFactory::getFloatingData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    hsize_t * dims = 0;
+    void * data = 0;
+    H5Data * dataObj = 0;
+    const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+    if (H5Tequal(nativeType, H5T_NATIVE_FLOAT))
     {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
-
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
-       if (H5Tis_variable_str(type))
-       {
-           return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char **)data);
-       }
-       else
-       {
-           return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char *)data);
-       }
+        dataObj = new H5FloatData(parent, totalSize, dataSize, ndims, dims, (float *)data);
     }
-
-    H5TimeData & H5DataFactory::getTimeData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    else if (H5Tequal(nativeType, H5T_NATIVE_DOUBLE))
     {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
+        dataObj = new H5BasicData<double>(parent, totalSize, dataSize, ndims, dims, (double *)data);
+    }
+    else
+    {
+        H5Tclose(nativeType);
+        delete[] dims;
+        delete[] static_cast<char *>(data);
+        throw H5Exception(__LINE__, __FILE__, _("Unknown floating-point datatype."));
+    }
 
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+    H5Tclose(nativeType);
 
-        return *new H5TimeData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
-    }
+    return *dataObj;
+}
 
-    H5BitfieldData & H5DataFactory::getBitfieldData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+H5StringData & H5DataFactory::getStringData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    hsize_t * dims = 0;
+    void * data = 0;
+
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+    if (H5Tis_variable_str(type))
     {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
-
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
-       
-        return *new H5BitfieldData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+        return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char **)data);
     }
-
-    H5OpaqueData & H5DataFactory::getOpaqueData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    else
     {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
-
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
-       
-        return *new H5OpaqueData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+        return *new H5StringData(parent, totalSize, dataSize, ndims, dims, (char *)data);
     }
+}
 
-    H5Data & H5DataFactory::getCompoundData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+H5TimeData & H5DataFactory::getTimeData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    hsize_t * dims = 0;
+    void * data = 0;
+
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+    return *new H5TimeData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+}
+
+H5BitfieldData & H5DataFactory::getBitfieldData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    hsize_t * dims = 0;
+    void * data = 0;
+
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+    return *new H5BitfieldData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+}
+
+H5OpaqueData & H5DataFactory::getOpaqueData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    hsize_t * dims = 0;
+    void * data = 0;
+
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+    return *new H5OpaqueData(parent, totalSize, dataSize, ndims, dims, static_cast<char *>(data));
+}
+
+H5Data & H5DataFactory::getCompoundData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    hsize_t * dims = 0;
+    void * data = 0;
+    const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+    try
     {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
-       const hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
-       getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
-
-       try
-       {
-           return getData(parent, totalSize, nativeType, ndims, dims, data, dataSize, 0, true);
-       }
-       catch (const H5Exception & e)
-       {
-           H5Tclose(nativeType);
-           throw;
-       }
+        return getData(parent, totalSize, nativeType, ndims, dims, data, dataSize, 0, true);
     }
-
-    H5ReferenceData & H5DataFactory::getReferenceData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+    catch (const H5Exception & e)
     {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hsize_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
-
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
-       std::cout << "ref size = " << ndims << std::endl; 
-        return *new H5ReferenceData(parent, H5Tequal(type, H5T_STD_REF_DSETREG) > 0, totalSize, dataSize, ndims, dims, (char *)data);
+        H5Tclose(nativeType);
+        throw;
     }
+}
 
-    /*H5EnumData & H5DataFactory::getEnumData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
-    {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hisze_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
-        int nmembers = H5Tget_nmembers(type);
-        std::string * names = new std::string[nmembers];
-
-        for (unsigned int i = 0; i < nmembers; i++)
-        {
-            char * mname = H5Tget_member_name(type, i);
-            names[i] = std::string(mname);
-            free(mname);
-        }
+H5ReferenceData & H5DataFactory::getReferenceData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+{
+    hsize_t ndims;
+    hsize_t totalSize;
+    hsize_t dataSize;
+    hsize_t * dims = 0;
+    void * data = 0;
+
+    getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+    return *new H5ReferenceData(parent, H5Tequal(type, H5T_STD_REF_DSETREG) > 0, totalSize, dataSize, ndims, dims, (char *)data);
+}
 
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+/*H5EnumData & H5DataFactory::getEnumData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+  {
+  hsize_t ndims;
+  hsize_t totalSize;
+  hisze_t dataSize;
+  hsize_t * dims = 0;
+  void * data = 0;
+  int nmembers = H5Tget_nmembers(type);
+  std::string * names = new std::string[nmembers];
 
-        return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, data, names);
-    }
+  for (unsigned int i = 0; i < nmembers; i++)
+  {
+  char * mname = H5Tget_member_name(type, i);
+  names[i] = std::string(mname);
+  free(mname);
+  }
 
-    H5VlenData & H5DataFactory::getVlenData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
-    {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hisze_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
+  getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
 
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+  return *new H5EnumData(parent, totalSize, dataSize, ndims, dims, data, names);
+  }
 
-        return *new H5VlenData(parent, totalSize, dataSize, ndims, dims, data);
-    }
+  H5VlenData & H5DataFactory::getVlenData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+  {
+  hsize_t ndims;
+  hsize_t totalSize;
+  hisze_t dataSize;
+  hsize_t * dims = 0;
+  void * data = 0;
 
-    H5ArrayData & H5DataFactory::getArrayData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
-    {
-        hsize_t ndims;
-       hsize_t totalSize;
-       hisze_t dataSize;
-        hsize_t * dims = 0;
-        void * data = 0;
+  getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+
+  return *new H5VlenData(parent, totalSize, dataSize, ndims, dims, data);
+  }
 
-        getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+  H5ArrayData & H5DataFactory::getArrayData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute)
+  {
+  hsize_t ndims;
+  hsize_t totalSize;
+  hisze_t dataSize;
+  hsize_t * dims = 0;
+  void * data = 0;
 
-        return *new H5ArrayData(parent, totalSize, dataSize, ndims, dims, data);
-       }*/
+  getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
 
-    //  getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
+  return *new H5ArrayData(parent, totalSize, dataSize, ndims, dims, data);
+  }*/
 
-    //return *new H5StringData(parent, totalSize, dataSize, ndims, dims, data);
+//  getNativeData(obj, type, &totalSize, &dataSize, &ndims, &dims, &data, isAttribute);
 
-    void H5DataFactory::getNativeData(const hid_t obj, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, void ** data, const bool isAttribute)
+//return *new H5StringData(parent, totalSize, dataSize, ndims, dims, data);
+
+void H5DataFactory::getNativeData(const hid_t obj, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, void ** data, const bool isAttribute)
+{
+    hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
+    const hid_t space = isAttribute ? H5Aget_space(obj) : H5Dget_space(obj);
+    hsize_t size = H5Tget_size(nativeType);
+    *totalSize = 1;
+    *dims = new hsize_t[__SCILAB_HDF5_MAX_DIMS__ + 1]();
+    *ndims = H5Sget_simple_extent_dims(space, *dims, 0);
+
+    if (H5Tget_class(nativeType) == H5T_STRING && !H5Tis_variable_str(nativeType))
     {
-        hid_t nativeType = H5Tget_native_type(type, H5T_DIR_DEFAULT);
-       const hid_t space = isAttribute ? H5Aget_space(obj) : H5Dget_space(obj);
-        hsize_t size = H5Tget_size(nativeType);
-       *totalSize = 1;
-       *dims = new hsize_t[__SCILAB_HDF5_MAX_DIMS__ + 1];
-        *ndims = H5Sget_simple_extent_dims(space, *dims, 0);
-
-        if (H5Tget_class(nativeType) == H5T_STRING && !H5Tis_variable_str(nativeType))
-        {
-            // We have a C-string so it is null terminated
-            size++;
-        }
+        // We have a C-string so it is null terminated
+        size++;
+    }
 
-       *dataSize = size;
+    *dataSize = size;
 
-        for (int i = 0; i < *ndims; i++)
-        {
-            *totalSize *= (*dims)[i];
-        }
+    for (int i = 0; i < *ndims; i++)
+    {
+        *totalSize *= (*dims)[i];
+    }
 
-       size *= *totalSize;
+    size *= *totalSize;
 
-        if ((hsize_t)((size_t)size) != size)
-        {
-           H5Tclose(type);
-            H5Tclose(nativeType);
-            H5Sclose(space);
-            delete[] *dims;
-            throw H5Exception(__LINE__, __FILE__, _("Memory to allocate is too big"));
-        }
+    if ((hsize_t)((size_t)size) != size)
+    {
+        H5Tclose(type);
+        H5Tclose(nativeType);
+        H5Sclose(space);
+        delete[] *dims;
+        throw H5Exception(__LINE__, __FILE__, _("Memory to allocate is too big"));
+    }
 
-        *data = MALLOC((size_t)size);
-        if (!*data)
-        {
-           H5Tclose(type);
-            H5Tclose(nativeType);
-            H5Sclose(space);
-            delete[] *dims;
-            throw H5Exception(__LINE__, __FILE__, _("Cannot allocate memory to get the data"));
-        }
+    *data = static_cast<void *>(new char[(size_t)size]());
+    if (!*data)
+    {
+        H5Tclose(type);
+        H5Tclose(nativeType);
+        H5Sclose(space);
+        delete[] *dims;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot allocate memory to get the data"));
+    }
 
-        if ((isAttribute && H5Aread(obj, nativeType, *data) < 0)
+    if ((isAttribute && H5Aread(obj, nativeType, *data) < 0)
             || (!isAttribute && H5Dread(obj, nativeType, H5S_ALL, H5S_ALL, H5P_DEFAULT, *data) < 0))
-        {
-           H5Tclose(type);
-            H5Tclose(nativeType);
-            H5Sclose(space);
-            FREE(*data);
-            delete[] *dims;
-            throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve the data from the attribute"));
-        }
-
+    {
+        H5Tclose(type);
         H5Tclose(nativeType);
         H5Sclose(space);
+        delete[] static_cast<char *>(*data);
+        delete[] *dims;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve the data from the attribute"));
     }
-}
 
-#undef __SCILAB_HDF5_MAX_DIMS__
+    H5Tclose(nativeType);
+    H5Sclose(space);
+}
+}
index ad6dfda..13c0a37 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef __H5DATAFACTORY_HXX__
 #define __H5DATAFACTORY_HXX__
 
+#include "HDF5Objects.h"
 #include "H5Object.hxx"
 #include "H5Data.hxx"
 #include "H5StringData.hxx"
 #include "H5CompoundData.hxx"
 #include "H5OpaqueData.hxx"
 #include "H5FloatData.hxx"
+#include "H5CharData.hxx"
+#include "H5UnsignedCharData.hxx"
 
 namespace org_modules_hdf5
 {
-    class H5DataFactory
-    {
-       
-    public:
-       
-       static H5Data & getData(H5Object & parent, const hid_t obj, const bool isAttribute);
-       static H5Data & getData(H5Object & parent, const hsize_t totalSize, const hid_t type, hsize_t ndims, hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner = false);
-       static H5Data & getIntegerData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static H5Data & getFloatingData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static H5StringData & getStringData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static H5TimeData & getTimeData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static H5BitfieldData & getBitfieldData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static H5OpaqueData & getOpaqueData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static H5Data & getCompoundData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static H5ReferenceData & getReferenceData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
-       static void getNativeData(const hid_t obj, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, void ** data, const bool isAttribute);
-    };
+class H5DataFactory
+{
+
+public:
+
+    static H5Data & getData(H5Object & parent, const hid_t obj, const bool isAttribute);
+    static H5Data & getData(H5Object & parent, const hsize_t totalSize, const hid_t type, hsize_t ndims, hsize_t * dims, void * data, const hsize_t stride, const size_t offset, const bool dataOwner = false);
+    static H5Data & getIntegerData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static H5Data & getFloatingData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static H5StringData & getStringData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static H5TimeData & getTimeData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static H5BitfieldData & getBitfieldData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static H5OpaqueData & getOpaqueData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static H5Data & getCompoundData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static H5ReferenceData & getReferenceData(H5Object & parent, const hid_t obj, const hid_t type, const bool isAttribute);
+    static void getNativeData(const hid_t obj, const hid_t type, hsize_t * totalSize, hsize_t * dataSize, hsize_t * ndims, hsize_t ** dims, void ** data, const bool isAttribute);
+};
 }
 
 #endif // __H5DATAFACTORY_HXX__
index e3e086d..52b0883 100644 (file)
 
 #include "H5Dataset.hxx"
 #include "H5DataFactory.hxx"
+#include "H5Attribute.hxx"
+#include "H5HardLink.hxx"
 
 namespace org_modules_hdf5
 {
-    
-    H5Dataset::H5Dataset(H5Object & _parent, const char * _name) : H5Object(_parent), name(_name), dataset((hid_t)-1)
+
+void H5Dataset::init()
+{
+    dataset = H5Dopen2(getParent().getH5Id(), name.c_str(), H5P_DEFAULT);
+    if (dataset < 0)
     {
-       dataset = H5Dopen2(_parent.getH5Id(), name, H5P_DEFAULT);
-       if (dataset < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot open the given dataset %s."), name);
-       }
+        throw H5Exception(__LINE__, __FILE__, _("Cannot open the given dataset %s."), name.c_str());
     }
+}
+
+H5Dataset::H5Dataset(H5Object & _parent, const char * _name) : H5Object(_parent), name(std::string(_name)), dataset((hid_t) - 1)
+{
+    init();
+}
+
+H5Dataset::H5Dataset(H5Object & _parent, const std::string & _name) : H5Object(_parent), name(_name), dataset((hid_t) - 1)
+{
+    init();
+}
+
+H5Dataset::H5Dataset(H5Object & _parent, hid_t _dataset, const char * _name) : H5Object(_parent), dataset(_dataset), name(std::string(_name))
+{
+
+}
+
+H5Dataset::H5Dataset(H5Object & _parent, hid_t _dataset, const std::string & _name) : H5Object(_parent), dataset(_dataset), name(_name)
+{
 
-    H5Dataset::H5Dataset(H5Object & _parent, hid_t _dataset, const char * _name) : H5Object(_parent), dataset(_dataset), name(_name)
+}
+
+H5Dataset::~H5Dataset()
+{
+    if (dataset >= 0)
     {
+        H5Dclose(dataset);
+    }
+}
+
+H5Data & H5Dataset::getData()
+{
+    return H5DataFactory::getData(*this, dataset, false);
+}
 
+H5Dataspace & H5Dataset::getSpace()
+{
+    hid_t space = H5Dget_space(dataset);
+    if (space < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the dataspace associated with dataset named %s."), name.c_str());
     }
 
-    H5Dataset::~H5Dataset()
+    return *new H5Dataspace(*this, space);
+}
+
+H5Type & H5Dataset::getDataType()
+{
+    hid_t type = H5Dget_type(dataset);
+    if (type < 0)
     {
-       if (dataset >= 0)
-       {
-           H5Dclose(dataset);
-       }
-       if (name)
-       {
-           FREE(const_cast<char *>(name));
-       }
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the dataspace associated with dataset named %s."), name.c_str());
     }
 
-    H5Data & H5Dataset::getData()
+    return *new H5Type(*this, type);
+}
+
+H5Dataset::H5Layout & H5Dataset::getLayout()
+{
+    hid_t plist = H5Dget_create_plist(dataset);
+    H5D_layout_t layout = H5Pget_layout(plist);
+    H5Dataset::H5Layout * obj = 0;
+
+    switch (layout)
     {
-       return H5DataFactory::getData(*this, dataset, false);
+        case H5D_COMPACT:
+            obj = new H5Dataset::H5CompactLayout(*this);
+            break;
+        case H5D_CONTIGUOUS:
+            obj = new H5Dataset::H5ContiguousLayout(*this);
+            break;
+        case H5D_CHUNKED:
+            obj = new H5Dataset::H5ChunkedLayout(*this);
+            break;
+        default:
+            H5Pclose(plist);
+            throw H5Exception(__LINE__, __FILE__, _("Invalid layout"));
     }
-    
-    H5Dataspace & H5Dataset::getSpace()
+
+    H5Pclose(plist);
+
+    return *obj;
+}
+
+void H5Dataset::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    SciErr err;
+    std::string lower(_name);
+
+    try
     {
-       hid_t space = H5Dget_space(dataset);
-       if (space < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot get the dataspace associated with dataset named %s."), name);
-       }
-       
-       return *new H5Dataspace(*this, space);
+        H5Attribute * attr = new H5Attribute(*const_cast<H5Dataset *>(this), _name);
+        attr->createOnScilabStack(pos, pvApiCtx);
+
+        return;
     }
+    catch (H5Exception & e) { }
 
-    H5Type & H5Dataset::getDataType()
+    std::transform(_name.begin(), _name.end(), lower.begin(), tolower);
+
+    if (lower == "attributes")
     {
-       hid_t type = H5Dget_type(dataset);
-       if (type < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot get the dataspace associated with dataset named %s."), name);
-       }
-       
-       return *new H5Type(*this, type);
+        const H5AttributesList & attrs = const_cast<H5Dataset *>(this)->getAttributes();
+        attrs.createOnScilabStack(pos, pvApiCtx);
+
+        return;
     }
+    else if (lower == "type")
+    {
+        const H5Type & type = const_cast<H5Dataset *>(this)->getDataType();
+        type.createOnScilabStack(pos, pvApiCtx);
 
-    std::string H5Dataset::dump(const unsigned int indentLevel) const
-    { 
-       std::ostringstream os;
-       const H5Type & type = const_cast<H5Dataset *>(this)->getDataType();
-       const H5Dataspace & space = const_cast<H5Dataset *>(this)->getSpace();
-       const H5AttributesList & attrs = const_cast<H5Dataset *>(this)->getAttributes();
-       const H5Data & data = const_cast<H5Dataset *>(this)->getData();
+        return;
+    }
+    else if (lower == "dataspace")
+    {
+        const H5Dataspace & space = const_cast<H5Dataset *>(this)->getSpace();
+        space.createOnScilabStack(pos, pvApiCtx);
 
-       os << H5Object::getIndentString(indentLevel) << "DATASET \"" << name << "\" {" << std::endl
-           << type.dump(indentLevel + 1)
-           << space.dump(indentLevel + 1)
-           << data.dump(indentLevel + 1)
-           << attrs.dump(indentLevel + 1)
-          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+        return;
+    }
+    else if (lower == "data")
+    {
+        const H5Data & data = const_cast<H5Dataset *>(this)->getData();
+        data.toScilab(pvApiCtx, pos);
 
-       delete &type;
-       delete &space;
-       delete &data;
-       delete &attrs;
-       
-       return os.str();
-    } 
+        delete &data;
 
-    std::string H5Dataset::toString(const unsigned int indentLevel) const
-    { 
-       return "";
+        return;
     }
+    else if (lower == "layout")
+    {
+        const H5Dataset::H5Layout & layout = const_cast<H5Dataset *>(this)->getLayout();
+        layout.createOnScilabStack(pos, pvApiCtx);
+
+        return;
+    }
+
+    H5Object::getAccessibleAttribute(_name, pos, pvApiCtx);
+}
+
+std::string H5Dataset::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    haddr_t addr = this->getAddr();
+    std::map<haddr_t, std::string>::iterator it = alreadyVisited.find(addr);
+    if (it != alreadyVisited.end())
+    {
+        os << H5Object::getIndentString(indentLevel) << "DATASET \"" << getName() << "\" {" << std::endl
+           << H5Object::getIndentString(indentLevel + 1) << "HARDLINK \"" << it->second << "\"" << std::endl
+           << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+        return os.str();
+    }
+    else
+    {
+        alreadyVisited.insert(std::pair<haddr_t, std::string>(addr, getCompletePath()));
+    }
+
+    const H5Type & type = const_cast<H5Dataset *>(this)->getDataType();
+    const H5Dataspace & space = const_cast<H5Dataset *>(this)->getSpace();
+    const H5AttributesList & attrs = const_cast<H5Dataset *>(this)->getAttributes();
+    const H5Data & data = const_cast<H5Dataset *>(this)->getData();
+    const H5Dataset::H5Layout & layout = const_cast<H5Dataset *>(this)->getLayout();
+
+    os << H5Object::getIndentString(indentLevel) << "DATASET \"" << getName() << "\" {" << std::endl
+       << type.dump(alreadyVisited, indentLevel + 1)
+       << space.dump(alreadyVisited, indentLevel + 1)
+       << layout.dump(alreadyVisited, indentLevel + 1)
+       << data.dump(alreadyVisited, indentLevel + 1)
+       << attrs.dump(alreadyVisited, indentLevel + 1)
+       << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+    delete &type;
+    delete &space;
+    delete &data;
+    delete &attrs;
+    delete &layout;
+
+    return os.str();
+}
+
+void H5Dataset::printLsInfo(std::ostringstream & os) const
+{
+    const H5Dataspace & space = const_cast<H5Dataset *>(this)->getSpace();
+    std::vector<unsigned int> dims = space.getDims();
+    std::string str(getName());
+    H5Object::getResizedString(str);
+
+    os << str << "Dataset {";
+
+    if (dims.size() == 0)
+    {
+        os << "}";
+    }
+    else
+    {
+        for (unsigned int i = 0; i < dims.size() - 1; i++)
+        {
+            os << dims[i] << ", ";
+        }
+        os << dims[dims.size() - 1] << "}";
+    }
+
+    delete &space;
+
+    os << std::endl;
+}
+
+std::string H5Dataset::ls() const
+{
+    std::ostringstream os;
+    printLsInfo(os);
+
+    return os.str();
+}
+
+std::string H5Dataset::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel + 1);
+    const H5Type & type = const_cast<H5Dataset *>(this)->getDataType();
+    const H5AttributesList & attrs = const_cast<H5Dataset *>(this)->getAttributes();
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 Dataset" << std::endl
+       << indentString << _("Filename") << ": " << getParent().getFile().getFileName() << std::endl
+       << indentString << _("Name") << ": " << getName() << std::endl
+       << indentString << _("Path") << ": " << getCompletePath() << std::endl
+       << indentString << _("Elements type") << ": " << type.getTypeName() << std::endl
+       << indentString << _("Attributes") << ": [1 x " << attrs.getSize() << "]";
+
+    delete &type;
+    delete &attrs;
+
+    return os.str();
+}
+
+hid_t H5Dataset::create(H5Object & loc, const std::string & name, hid_t type, hid_t targettype, hid_t space, void * data)
+{
+    herr_t err;
+    hid_t dataset = H5Dcreate2(loc.getH5Id(), name.c_str(), targettype, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+    if (dataset < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot create a new dataset."));
+    }
+
+    err = H5Dwrite(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+    if (err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot write data in the dataset."));
+    }
+
+    return dataset;
+}
 }
index 0d80f7a..19f9728 100644 (file)
 #include "H5Type.hxx"
 #include "H5AttributesList.hxx"
 
+#define __HDF5_SCILAB_NAME_LENGTH__ 256
+
 namespace org_modules_hdf5
 {
-    class H5Dataset : public H5Object
+class H5Dataset : public H5Object
+{
+    hid_t dataset;
+    const std::string name;
+
+public :
+
+    H5Dataset(H5Object & _parent, const char * _name);
+    H5Dataset(H5Object & _parent, const std::string & _name);
+    H5Dataset(H5Object & _parent, hid_t _dataset, const char * _name);
+    H5Dataset(H5Object & _parent, hid_t _dataset, const std::string & _name);
+
+    virtual ~H5Dataset();
+
+    hid_t getH5Id() const
+    {
+        return dataset;
+    }
+
+    virtual bool checkType(const int type) const
+    {
+        return type == H5O_TYPE_DATASET;
+    }
+
+    virtual const std::string & getName() const
+    {
+        return name;
+    }
+
+    H5Data & getData();
+    H5Dataspace & getSpace();
+    H5Type & getDataType();
+
+    virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const;
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+    virtual std::string toString(const unsigned int indentLevel) const;
+    virtual std::string ls() const;
+    virtual void printLsInfo(std::ostringstream & os) const;
+
+    class H5Layout : public H5Object
+    {
+
+    public :
+
+        H5Layout(H5Object & _parent) : H5Object(_parent) { }
+
+        virtual hsize_t getStorageSize() const
+        {
+            return H5Dget_storage_size(parent.getH5Id());
+        }
+
+        virtual haddr_t getIOffset() const
+        {
+            return H5Dget_offset(parent.getH5Id());
+        }
+
+        virtual int getExternalCount() const
+        {
+            hid_t plist = H5Dget_create_plist(parent.getH5Id());
+            int count = H5Pget_external_count(plist);
+
+            H5Pclose(plist);
+            return count;
+        }
+
+        virtual ~H5Layout() { }
+    };
+
+    class H5CompactLayout : public H5Layout
+    {
+
+    public :
+
+        H5CompactLayout(H5Object & _parent) : H5Layout(_parent) { }
+
+        virtual ~H5CompactLayout() { }
+
+        virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const
+        {
+            std::ostringstream os;
+            std::string indent = H5Object::getIndentString(indentLevel);
+            std::string indent1 = H5Object::getIndentString(indentLevel + 1);
+
+            os << indent << "STORAGE_LAYOUT {" << std::endl
+               << indent1 << "COMPACT" << std::endl
+               << indent1 << "SIZE " << getStorageSize() << std::endl
+               << indent << "}" << std::endl;
+
+            return os.str();
+        }
+    };
+
+    class H5ChunkedLayout : public H5Layout
+    {
+
+    public :
+
+        H5ChunkedLayout(H5Object & _parent) : H5Layout(_parent) { }
+
+        virtual ~H5ChunkedLayout() { }
+
+        virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const
+        {
+            std::ostringstream os;
+            std::string indent = H5Object::getIndentString(indentLevel);
+            std::string indent1 = H5Object::getIndentString(indentLevel + 1);
+            // TODO: chunked est a finir (cf h5dump.c::2758)
+            os << indent << "STORAGE_LAYOUT {" << std::endl
+               << indent1 << "CHUNKED" << std::endl
+               << indent1 << "SIZE " << getStorageSize() << std::endl
+               << indent << "}" << std::endl;
+
+            return os.str();
+        }
+    };
+
+    class H5ContiguousLayout : public H5Layout
     {
-       hid_t dataset;
-       const char * name;
 
     public :
-       
-       H5Dataset(H5Object & _parent, const char * _name);
-       H5Dataset(H5Object & _parent, hid_t _dataset, const char * _name);
-
-       virtual ~H5Dataset();
-
-       hid_t getH5Id() const { return dataset; }
-       std::string getName() const { return std::string(name); }
-       
-       H5Data & getData();
-       H5Dataspace & getSpace();
-       H5Type & getDataType();
-       
-       virtual std::string dump(const unsigned int indentLevel) const;
-       virtual std::string toString(const unsigned int indentLevel) const;
+
+        H5ContiguousLayout(H5Object & _parent) : H5Layout(_parent) { }
+
+        virtual ~H5ContiguousLayout() { }
+
+        virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const
+        {
+            std::ostringstream os;
+            std::string indent = H5Object::getIndentString(indentLevel);
+            std::string indent1 = H5Object::getIndentString(indentLevel + 1);
+            unsigned int extCount = (unsigned int)getExternalCount();
+
+            os << indent << "STORAGE_LAYOUT {" << std::endl
+               << indent1 << "CONTIGUOUS" << std::endl;
+
+            if (extCount)
+            {
+                hid_t plist = H5Dget_create_plist(parent.getH5Id());
+                for (unsigned int i = 0; i < extCount; i++)
+                {
+                    off_t offset;
+                    hsize_t size;
+                    char name[__HDF5_SCILAB_NAME_LENGTH__];
+                    H5Pget_external(plist, i, __HDF5_SCILAB_NAME_LENGTH__, name, &offset, &size);
+                    os << indent1 << "FILENAME " << name << " SIZE " << size << " OFFSET " << offset << std::endl;
+                }
+                H5Pclose(plist);
+            }
+            else
+            {
+                os << indent1 << "SIZE " << getStorageSize() << std::endl
+                   << indent1 << "OFFSET " << getIOffset() << std::endl;
+            }
+
+            os << indent << "}" << std::endl;
+
+            return os.str();
+        }
     };
+
+    H5Layout & getLayout();
+
+    static hid_t create(H5Object & loc, const std::string & name, hid_t type, hid_t targettype, hid_t space, void * data);
+
+private:
+
+    void init();
+};
 }
 
 #endif // __H5DATASET_HXX__
index 15c309a..089ffc8 100644 (file)
 namespace org_modules_hdf5
 {
 
-    H5DatasetsList::H5DatasetsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_DATASET, "H5 Dataset")
-    {
-    
-    }
-       
-    H5DatasetsList::~H5DatasetsList()
-    {
+H5DatasetsList::H5DatasetsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_DATASET, "H5 Dataset")
+{
+
+}
 
-    }
+H5DatasetsList::~H5DatasetsList()
+{
+
+}
 }
index 6091ff6..19f10f2 100644 (file)
 namespace org_modules_hdf5
 {
 
-    class H5Group;
+class H5Group;
 
-    class H5DatasetsList : public H5NamedObjectsList<H5Dataset>
-    {
+class H5DatasetsList : public H5NamedObjectsList<H5Dataset>
+{
+
+public :
+
+    H5DatasetsList(H5Group & _parent) : H5NamedObjectsList<H5Dataset>(_parent, H5G_DATASET, -1, "H5 Dataset") { }
 
-    public :
-       
-       H5DatasetsList(H5Group & _parent) : H5NamedObjectsList<H5Dataset>(_parent, H5G_DATASET, "H5 Dataset") { }
-       
-       ~H5DatasetsList() { }
-    };
+    ~H5DatasetsList() { }
+};
 }
 
 #endif // __H5DATASETSLIST_HXX__
index c0e2e34..2cd0ebb 100644 (file)
  *
  */
 
+#include "H5File.hxx"
 #include "H5Dataspace.hxx"
 
 namespace org_modules_hdf5
 {
-    
-    H5Dataspace::H5Dataspace(H5Object & _parent, hid_t _space) : H5Object(_parent), space(_space)
+
+H5Dataspace::H5Dataspace(H5Object & _parent, hid_t _space) : H5Object(_parent), space(_space)
+{
+}
+
+H5Dataspace::~H5Dataspace()
+{
+    if (space >= 0)
     {
+        H5Sclose(space);
     }
+}
 
-    H5Dataspace::~H5Dataspace()
+hid_t H5Dataspace::getH5Id()
+{
+    return space;
+}
+
+std::string H5Dataspace::getTypeName() const
+{
+    H5S_class_t _class = H5Sget_simple_extent_type(space);
+    switch (_class)
     {
-       if (space >= 0)
-       {
-           H5Sclose(space);
-       }
+        case H5S_SCALAR:
+            return "scalar";
+        case H5S_SIMPLE:
+            return "simple";
+        case H5S_NULL:
+            return "null";
+        case H5S_NO_CLASS:
+            return "no class";
+        default:
+            return std::string(_("unknown dataspace"));
     }
+}
+
+std::vector<unsigned int> H5Dataspace::getDims() const
+{
+    hsize_t dims[__SCILAB_HDF5_MAX_DIMS__];
+    hsize_t maxdims[__SCILAB_HDF5_MAX_DIMS__];
+    int ndims;
+    std::vector<unsigned int> vdims;
+    H5S_class_t _class = H5Sget_simple_extent_type(space);
+
+    switch (_class)
+    {
+        case H5S_SCALAR:
+            vdims.push_back(1);
+            break;
+        case H5S_SIMPLE:
+            ndims = H5Sget_simple_extent_dims(space, (hsize_t *)dims, (hsize_t *)maxdims);
+            vdims.reserve(ndims);
+            for (int i = 0; i < ndims; i++)
+            {
+                vdims.push_back(static_cast<unsigned int>(dims[i]));
+            }
+            break;
+        case H5S_NULL:
+            vdims.push_back(0);
+            break;
+        case H5S_NO_CLASS:
+        default:
+            throw H5Exception(__LINE__, __FILE__, _("Unknown dataspace: cannot get its dimensions"));
+    }
+
+    return vdims;
+}
+
+void H5Dataspace::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    SciErr err;
+    std::string lower(_name);
+    std::transform(_name.begin(), _name.end(), lower.begin(), tolower);
 
-    hid_t H5Dataspace::getH5Id()
+    if (lower == "dimensions")
     {
-       return space;
+        std::vector<unsigned int> dims = getDims();
+        err = createMatrixOfUnsignedInteger32(pvApiCtx, pos, 1, dims.size(), &(dims[0]));
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an array of integer on the stack."));
+        }
+
+        return;
     }
-    
-    std::string H5Dataspace::dump(unsigned int indentLevel) const
+    else if (lower == "type")
     {
-       std::ostringstream os;
-       hsize_t dims[64];
-       hsize_t maxdims[64];
-       int ndims;
-       H5S_class_t _class = H5Sget_simple_extent_type(space);
-       
-       os << H5Object::getIndentString(indentLevel);
-
-       switch (_class)
-       {
-       case H5S_SCALAR:
-           os << "DATASPACE SCALAR";
-           break;
-       case H5S_SIMPLE:
-           os << "DATASPACE SIMPLE { ";
-           ndims = H5Sget_simple_extent_dims(space, (hsize_t *)dims, (hsize_t *)maxdims);
-           os << "( ";
-           for (int i = 0; i < ndims - 1; i++)
-           {
-               os << dims[i] << ", ";
-           }
-           os << dims[ndims -1] << " ) / ( ";
-           for (int i = 0; i < ndims - 1; i++)
-           {
-               if (maxdims[i] == H5S_UNLIMITED)
-               {
-                   os << "H5S_UNLIMITED, ";
-               }
-               else
-               {
-                   os << maxdims[i] << ", ";
-               }
-           }
-           if (maxdims[ndims - 1] == H5S_UNLIMITED)
-           {
-               os << "H5S_UNLIMITED ) }";
-           }
-           else
-           {
-               os << maxdims[ndims - 1] << " ) }";
-           }
-           break;
-       case H5S_NULL:
-           os << "DATASPACE NULL";
-           break;
-       case H5S_NO_CLASS:
-       default:
-           os << _("Unknown dataspace");
-       }
-       
-       os << std::endl;
-
-       return os.str();
+        std::string type = getTypeName();
+        const char * _type = type.c_str();
+        err = createMatrixOfString(pvApiCtx, pos, 1, 1, &_type);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a string on the stack."));
+        }
+
+        return;
     }
 
-    std::string H5Dataspace::toString(unsigned int indentLevel) const
+    H5Object::getAccessibleAttribute(_name, pos, pvApiCtx);
+}
+
+std::string H5Dataspace::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    hsize_t dims[__SCILAB_HDF5_MAX_DIMS__];
+    hsize_t maxdims[__SCILAB_HDF5_MAX_DIMS__];
+    int ndims;
+    H5S_class_t _class = H5Sget_simple_extent_type(space);
+
+    os << H5Object::getIndentString(indentLevel);
+
+    switch (_class)
     {
-       return "";
+        case H5S_SCALAR:
+            os << "DATASPACE SCALAR";
+            break;
+        case H5S_SIMPLE:
+            os << "DATASPACE SIMPLE { ";
+            ndims = H5Sget_simple_extent_dims(space, (hsize_t *)dims, (hsize_t *)maxdims);
+            os << "( ";
+            for (int i = 0; i < ndims - 1; i++)
+            {
+                os << dims[i] << ", ";
+            }
+            os << dims[ndims - 1] << " ) / ( ";
+            for (int i = 0; i < ndims - 1; i++)
+            {
+                if (maxdims[i] == H5S_UNLIMITED)
+                {
+                    os << "H5S_UNLIMITED, ";
+                }
+                else
+                {
+                    os << maxdims[i] << ", ";
+                }
+            }
+            if (maxdims[ndims - 1] == H5S_UNLIMITED)
+            {
+                os << "H5S_UNLIMITED ) }";
+            }
+            else
+            {
+                os << maxdims[ndims - 1] << " ) }";
+            }
+            break;
+        case H5S_NULL:
+            os << "DATASPACE NULL";
+            break;
+        case H5S_NO_CLASS:
+        default:
+            os << _("Unknown dataspace");
     }
+
+    os << std::endl;
+
+    return os.str();
+}
+
+std::string H5Dataspace::toString(unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel + 1);
+    std::string type = getTypeName();
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 Dataspace" << std::endl
+       << indentString << _("Filename") << ": " << getParent().getFile().getFileName() << std::endl
+       << indentString << _("Name") << ": " << getName() << std::endl
+       << indentString << _("Path") << ": " << getCompletePath() << std::endl
+       << indentString << _("Type") << ": " << getTypeName();
+
+    if (type == "simple")
+    {
+        os << std::endl << indentString << _("Dimensions") << ": [1 x " << getDims().size() << "]";
+    }
+
+    return os.str();
+}
 }
index 9bc2e6e..570a1e7 100644 (file)
 #ifndef __H5DATASPACE_HXX__
 #define __H5DATASPACE_HXX__
 
+#include "HDF5Objects.h"
 #include "H5Object.hxx"
 
 namespace org_modules_hdf5
 {
-    
-    class H5Dataspace : public H5Object
-    {
-       hid_t space;
 
-    public:
+class H5Dataspace : public H5Object
+{
+    hid_t space;
+
+public:
+
+    H5Dataspace(H5Object & _parent, hid_t _space);
+    ~H5Dataspace();
+
+    virtual hid_t getH5Id();
+    virtual std::vector<unsigned int> getDims() const;
+    virtual std::string getTypeName() const;
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+    virtual std::string toString(const unsigned int indentLevel) const;
 
-       H5Dataspace(H5Object & _parent, hid_t _space);
-       ~H5Dataspace();
+    virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const;
 
-       virtual hid_t getH5Id();
-    
-       virtual std::string dump(unsigned int indentLevel) const;
-       virtual std::string toString(unsigned int indentLevel) const;
-    };
+    static H5Dataspace & createDataspace(H5Object & parent, const std::string & type);
+    static H5Dataspace & createDataspace(H5Object & parent, const int rank, const hsize_t * dims, const hsize_t * maxdims);
+};
 }
 
 #endif // __H5DATASPACE_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5EnumData.hxx b/scilab/modules/hdf5/src/cpp/H5EnumData.hxx
new file mode 100644 (file)
index 0000000..2db26fc
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5ENUMDATA_HXX__
+#define __H5ENUMDATA_HXX__
+
+#include "H5Data.hxx"
+
+namespace org_modules_hdf5
+{
+
+class H5EnumData : public H5BasicData<char>
+{
+
+public:
+
+    H5EnumData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, char * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5BasicData(_parent, _totalSize, _dataSize, _ndims + 1, _dims, _data, _stride, _offset, _dataOwner)
+    {
+        //dims[ndims - 1] = dataSize;
+    }
+
+    virtual ~H5EnumData()
+    {
+
+    }
+};
+}
+
+#endif // __H5ENUMDATA_HXX__
index e59b264..64dc810 100644 (file)
@@ -32,51 +32,51 @@ extern "C"
 
 namespace org_modules_hdf5
 {
-    class H5Exception
+class H5Exception : public std::exception
+{
+    std::string message;
+    std::string file;
+    int line;
+
+public :
+
+    H5Exception(const int _line, const char * _file, std::string _message, ...) : message(""), file(_file), line(_line)
+    {
+        char str[BUFFER_SIZE];
+        va_list args;
+
+        va_start(args, _message);
+        vsnprintf(str, BUFFER_SIZE, _message.c_str(), args);
+        va_end(args);
+
+        message = getDescription(std::string(str));
+    }
+
+    H5Exception(const int _line, const char * _file, const char * _message, ...) : message(""), file(_file), line(_line)
     {
-       std::string message;
-       std::string file;
-       int line;
-
-    public :
-       
-       H5Exception(const int _line, const char * _file, std::string _message, ...) : message(""), file(_file), line(_line)
-           {
-               char str[BUFFER_SIZE];
-               va_list args;
-               
-               va_start(args, _message);
-               vsnprintf(str, BUFFER_SIZE, _message.c_str(), args);
-               va_end(args);
-               
-               message = getDescription(std::string(str));
-           }
-
-       H5Exception(const int _line, const char * _file, const char * _message, ...) : message(""), file(_file), line(_line)
-           {
-               char str[BUFFER_SIZE];
-               va_list args;
-               
-               va_start(args, _message);
-               vsnprintf(str, BUFFER_SIZE, _message, args);
-               va_end(args);
-               
-               message = getDescription(std::string(str));
-           }
-       
-       virtual ~H5Exception() throw() { }
-
-       virtual const char * what() const throw()
-           {
-               return message.c_str();
-           }
+        char str[BUFFER_SIZE];
+        va_list args;
+
+        va_start(args, _message);
+        vsnprintf(str, BUFFER_SIZE, _message, args);
+        va_end(args);
+
+        message = getDescription(std::string(str));
+    }
+
+    virtual ~H5Exception() throw() { }
+
+    virtual const char * what() const throw()
+    {
+        return message.c_str();
+    }
 
 private:
 
     inline std::string getDescription(std::string m) const
     {
 
-#if defined(HDF5OBJECTS_DEBUG)
+#if defined(__HDF5OBJECTS_DEBUG__)
 
         if (line == -1)
         {
@@ -102,7 +102,7 @@ private:
 
 #endif
     }
-    };
+};
 }
 
 #endif // __H5EXCEPTION_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5ExternalLink.cpp b/scilab/modules/hdf5/src/cpp/H5ExternalLink.cpp
new file mode 100644 (file)
index 0000000..36061fe
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5ExternalLink.hxx"
+
+namespace org_modules_hdf5
+{
+
+std::vector<std::string *> H5ExternalLink::getLinkTargets() const
+{
+    herr_t err;
+    H5L_info_t info;
+    char * buf = 0;
+    std::vector<std::string *> ret;
+    const char * filename = 0;
+    const char * obj_path = 0;
+    unsigned int flags;
+
+    err = H5Lget_info(getParent().getH5Id(), getName().c_str(), &info, H5P_DEFAULT);
+    if (err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the link info"));
+    }
+
+    buf = new char[info.u.val_size];
+    err = H5Lget_val(getParent().getH5Id(), getName().c_str(), buf, info.u.val_size, H5P_DEFAULT);
+    if (err < 0)
+    {
+        delete[] buf;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the link target"));
+    }
+
+    // According to the doc the flags arg is useless
+    // For the future: follow the evolution of this argument.
+    err = H5Lunpack_elink_val(buf, info.u.val_size, 0, &filename, &obj_path);
+    if (err < 0)
+    {
+        delete[] buf;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the link target"));
+    }
+
+    ret.reserve(2);
+    ret[0] = new std::string(filename);
+    ret[1] = new std::string(obj_path);
+
+    delete[] buf;
+
+    return ret;
+}
+
+std::string H5ExternalLink::getLinkType() const
+{
+    return "external";
+}
+
+void H5ExternalLink::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    SciErr err;
+    std::string lower(_name);
+    std::transform(_name.begin(), _name.end(), lower.begin(), tolower);
+
+    if (lower == "type")
+    {
+        const char * _type = getLinkType().c_str();
+        err = createMatrixOfString(pvApiCtx, pos, 1, 1, &_type);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a string on the stack."));
+        }
+
+        return;
+    }
+    else if (lower == "target")
+    {
+        const char * _target[2];
+        std::vector<std::string *> target = getLinkTargets();
+        _target[0] = (*target[0]).c_str();
+        _target[1] = (*target[1]).c_str();
+
+        err = createMatrixOfString(pvApiCtx, pos, 1, 2, _target);
+        target.erase(target.begin(), target.end());
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a string on the stack."));
+        }
+
+        return;
+    }
+
+    H5Object::getAccessibleAttribute(_name, pos, pvApiCtx);
+}
+
+void H5ExternalLink::printLsInfo(std::ostringstream & os) const
+{
+    std::string str(getName());
+    H5Object::getResizedString(str);
+    std::vector<std::string *> target = getLinkTargets();
+
+    os << str << "External Link {" << *target[0] << "//" << *target[1] << "}" << std::endl;
+
+    target.erase(target.begin(), target.end());
+}
+
+std::string H5ExternalLink::ls() const
+{
+    std::ostringstream os;
+    printLsInfo(os);
+
+    return os.str();
+}
+
+std::string H5ExternalLink::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::vector<std::string *> target = getLinkTargets();
+
+    os << H5Object::getIndentString(indentLevel) << "EXTERNAL_LINK \"" << name << "\" {" << std::endl
+       << H5Object::getIndentString(indentLevel + 1) << "TARGETFILE \"" << *target[0] << "\"" << std::endl
+       << H5Object::getIndentString(indentLevel + 1) << "TARGETPATH \"" << *target[1] << "\"" << std::endl
+       << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+    target.erase(target.begin(), target.end());
+
+    return os.str();
+}
+
+std::string H5ExternalLink::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::vector<std::string *> target = getLinkTargets();
+    std::string indentString = H5Object::getIndentString(indentLevel);
+
+    os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+       << indentString << _("Link type") << ": " << getLinkType() << std::endl
+       << indentString << _("Link name") << ": " << name << std::endl
+       << indentString << _("Link path") << ": " << getCompletePath() << std::endl
+       << indentString << _("Link target file") << ": " << *target[0] << std::endl
+       << indentString << _("Link target path") << ": " << *target[1];
+
+    target.erase(target.begin(), target.end());
+
+    return os.str();
+}
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5ExternalLink.hxx b/scilab/modules/hdf5/src/cpp/H5ExternalLink.hxx
new file mode 100644 (file)
index 0000000..c957a49
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5EXTERNALLINK_HXX__
+#define __H5EXTERNALLINK_HXX__
+
+#include "H5Link.hxx"
+
+namespace org_modules_hdf5
+{
+
+class H5ExternalLink : public H5Link
+{
+public:
+
+    H5ExternalLink(H5Object & _parent, const char * name) : H5Link(_parent, name) { }
+    H5ExternalLink(H5Object & _parent, const std::string & name) : H5Link(_parent, name) { }
+
+    virtual ~H5ExternalLink() { }
+
+    virtual std::string toString(const unsigned int indentLevel) const;
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const;
+    virtual std::string ls() const;
+    virtual void printLsInfo(std::ostringstream & os) const;
+
+    std::vector<std::string *> getLinkTargets() const;
+    virtual std::string getLinkType() const;
+
+    virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const;
+};
+}
+
+#endif // __H5EXTERNALLINK_HXX__
index bbeec3e..9889433 100644 (file)
  *
  */
 
+#include "HDF5Objects.h"
 #include "H5Group.hxx"
 #include "H5File.hxx"
 
+extern "C"
+{
+#include "FileExist.h"
+}
+
 namespace org_modules_hdf5
 {
 
-    H5File::H5File(const char * _filename, const char * _path, const bool _readonly) : H5Object(H5Object::getRoot()), filename(strdup(_filename)), path(_path), root(0)
+void H5File::init()
+{
+    bool opened;
+
+#if !defined(__HDF5ERROR_PRINT__)
+    H5Eset_auto2(H5E_DEFAULT, 0, 0);
+#endif
+
+    switch (flags)
     {
-       if (!H5Fis_hdf5(_filename))
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Invalid hdf5 file: %s"), _filename);
-       }
+        case RDONLY:
+            if (!FileExist(const_cast<char *>(filename.c_str())) || H5Fis_hdf5(filename.c_str()) <= 0)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Invalid hdf5 file: %s"), filename.c_str());
+            }
+
+            file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
+            if (file < 0)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot open the given hdf5 file: %s"), filename.c_str());
+            }
+
+            opened = true;
+            break;
+        case RDWR:
+            if (!FileExist(const_cast<char *>(filename.c_str())) || H5Fis_hdf5(filename.c_str()) <= 0)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Invalid hdf5 file: %s"), filename.c_str());
+            }
+
+            file = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
+            if (file < 0)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot open the given hdf5 file: %s"), filename.c_str());
+            }
 
-       file = H5Fopen(_filename, _readonly ? H5F_ACC_RDONLY : H5F_ACC_RDWR, H5P_DEFAULT);
+            opened = true;
+            break;
+        case TRUNC:
+            file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+            if (file < 0)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create the given hdf5 file: %s"), filename.c_str());
+            }
 
-       if (file < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot open the given hdf5 file: %s"), _filename);
-       }
+            break;
+        case EXCL:
+            file = H5Fcreate(filename.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
+            if (file < 0)
+            {
+                throw H5Exception(__LINE__, __FILE__, _("Cannot create the given hdf5 file: %s"), filename.c_str());
+            }
+            break;
+        case APPEND:
+            if (FileExist(const_cast<char *>(filename.c_str())))
+            {
+                if (H5Fis_hdf5(filename.c_str()) > 0)
+                {
+                    file = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
+                    if (file < 0)
+                    {
+                        throw H5Exception(__LINE__, __FILE__, _("Cannot open the given hdf5 file: %s"), filename.c_str());
+                    }
+
+                    opened = true;
+                }
+                else
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot append the file (not HDF5): %s"), filename.c_str());
+                }
+            }
+            else
+            {
+                file = H5Fcreate(filename.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
+                if (file < 0)
+                {
+                    throw H5Exception(__LINE__, __FILE__, _("Cannot create the given hdf5 file: %s"), filename.c_str());
+                }
+            }
     }
 
-    H5File::~H5File()
+    if (opened && path != "/" && H5Lexists(file, path.c_str(), H5P_DEFAULT) <= 0)
     {
-       if (file >= 0)
-       {
-           H5Fclose(file);
-       }
-       FREE(const_cast<char *>(filename));
+        H5Fclose(file);
+        throw H5Exception(__LINE__, __FILE__, _("Invalid path: %s"), path.c_str());
     }
+}
+
+H5File::H5File(const char * _filename, const char * _path, const char * access) : H5Object(H5Object::getRoot()), filename(std::string(_filename)), path(std::string(_path)), flags(getFlags(std::string(access)))
+{
+    init();
+}
 
-    H5Group & H5File::getRootGroup()
+H5File::H5File(const std::string & _filename, const std::string & _path, const std::string & access) : H5Object(H5Object::getRoot()), filename(_filename), path(_path), flags(getFlags(access))
+{
+    init();
+}
+
+H5File::~H5File()
+{
+    if (file >= 0)
     {
-       if (!root)
-       {
-           root = new H5Group(*this, strdup("/"));
-       }
-       return *root;
+        H5Fclose(file);
     }
+}
 
-    std::string H5File::getCompletePath() const
+H5Object & H5File::getRoot()
+{
+    hid_t obj = H5Oopen(getH5Id(), path.c_str(), H5P_DEFAULT);
+    if (obj < 0)
     {
-       return "";
+        throw H5Exception(__LINE__, __FILE__, _("Invalid path: %s"), path.c_str());
     }
 
-    std::string H5File::dump(const unsigned int indentLevel) const
+    try
     {
-       std::ostringstream os;
-       H5Group & _root = const_cast<H5File *>(this)->getRootGroup();
-       os << H5Object::getIndentString(indentLevel) << "HDF5 \"" << filename << "\" {" << std::endl
-          << _root.dump(indentLevel + 1)
-          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+        return H5Object::getObject(*this, obj);
+    }
+    catch (H5Exception & e)
+    {
+        H5Oclose(obj);
+        throw;
+    }
+}
+
+std::string H5File::getCompletePath() const
+{
+    return "";
+}
 
-       return os.str();
+hsize_t H5File::getFileSize() const
+{
+    herr_t err;
+    hsize_t size = 0;
+
+    err = H5Fget_filesize(file, &size);
+    if (err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve file size: %s"), filename.c_str());
     }
 
-    std::string H5File::toString(const unsigned int indentLevel) const
+    return size;
+}
+
+void H5File::getFileHDF5Version(unsigned int * out) const
+{
+    herr_t err = H5get_libversion(out, out + 1, out + 2);
+    if (err < 0)
     {
-       herr_t err;
-       hsize_t size = 0;
-       std::ostringstream os;
-       unsigned int major = 0, minor = 0, release = 0;
-       std::string indentString = H5Object::getIndentString(indentLevel);
-
-       err = H5Fget_filesize(file, &size);
-       if (err < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve file size: %s"), filename); 
-       }
-
-       err = H5get_libversion(&major, &minor, &release);
-       os << indentString << _("Filename") << ": " << filename << std::endl
-          << indentString << _("HDF5 library version") << ": " << major << "." << minor << "." << release << std::endl
-          << indentString << _("File size") << ": " << size << std::endl
-          << indentString << _("Group name") << ": " << path << std::flush;
-
-       os << std::endl << "DEBUG FILE" << std::endl << dump(0) << std::endl;
-
-       return os.str();
+        throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve file version: %s"), filename.c_str());
     }
 }
+
+void H5File::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    SciErr err;
+    std::string lower(_name);
+    std::transform(_name.begin(), _name.end(), lower.begin(), tolower);
+
+    if (lower == "name")
+    {
+        const char * _filename = filename.c_str();
+        err = createMatrixOfString(pvApiCtx, pos, 1, 1, &_filename);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a string on the stack."));
+        }
+
+        return;
+    }
+    else if (lower == "size")
+    {
+        unsigned int size = (unsigned int)getFileSize();
+        err = createMatrixOfUnsignedInteger32(pvApiCtx, pos, 1, 1, &size);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an integer on the stack."));
+        }
+
+        return;
+    }
+    else if (lower == "version")
+    {
+        unsigned int version[3];
+        getFileHDF5Version(version);
+        err = createMatrixOfUnsignedInteger32(pvApiCtx, pos, 1, 3, (unsigned int *)version);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create an array of integer on the stack."));
+        }
+
+        return;
+    }
+    else if (lower == "root")
+    {
+        H5Object & root = const_cast<H5File *>(this)->getRoot();
+        root.createOnScilabStack(pos, pvApiCtx);
+
+        return;
+    }
+
+    throw H5Exception(__LINE__, __FILE__, _("Invalid field %s."), _name.c_str());
+}
+
+std::string H5File::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    H5Object & _root = const_cast<H5File *>(this)->getRoot();
+    os << H5Object::getIndentString(indentLevel) << "HDF5 \"" << filename << "\" {" << std::endl
+       << _root.dump(alreadyVisited, indentLevel + 1)
+       << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+    delete &_root;
+
+    return os.str();
+}
+
+std::string H5File::ls() const
+{
+    H5Object & _root = const_cast<H5File *>(this)->getRoot();
+    std::string str = _root.ls();
+    delete &_root;
+
+    return str;
+}
+
+std::string H5File::toString(const unsigned int indentLevel) const
+{
+    herr_t err;
+    hsize_t size = 0;
+    std::ostringstream os;
+    unsigned int major = 0, minor = 0, release = 0;
+    std::string indentString = H5Object::getIndentString(indentLevel + 1);
+
+    err = H5Fget_filesize(file, &size);
+    if (err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot retrieve file size: %s"), filename.c_str());
+    }
+
+    err = H5get_libversion(&major, &minor, &release);
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 File" << std::endl
+       << indentString << _("Filename") << ": " << filename << std::endl
+       << indentString << _("HDF5 library version") << ": " << major << "." << minor << "." << release << std::endl
+       << indentString << _("File size") << ": " << size << std::endl
+       << indentString << _("Root object") << ": " << path << std::flush;
+
+    return os.str();
+}
+}
index 9ba086d..0ecbf83 100644 (file)
 
 namespace org_modules_hdf5
 {
-    class H5Group;
+class H5Group;
 
-    class H5File : public H5Object
+class H5File : public H5Object
+{
+    enum FileAccess { RDONLY, RDWR, TRUNC, EXCL, APPEND };
+
+    const std::string filename;
+    const std::string path;
+    const FileAccess flags;
+    hid_t file;
+
+
+public :
+
+    H5File(const char * _filename, const char * _path, const char * access = "a");
+    H5File(const std::string & _filename, const std::string & _path, const std::string & access = "a");
+
+    ~H5File();
+
+    virtual H5Object & getRoot();
+    virtual hid_t getH5Id() const
     {
-       const char * filename;
-       const char * path;
-       hid_t file;
-       H5Group * root;
-
-    public :
-       
-       H5File(const char * _filename, const char * _path = "/", const bool _readonly = false);
-       
-       ~H5File();
-
-       H5Group & getRootGroup();
-       hid_t getH5Id() const { return file; }
-       virtual std::string getCompletePath() const;
-       const char * getFileName() const { return filename; }
-       const char * getRootPath() const { return path; }
-
-       virtual std::string toString(const unsigned int indentLevel) const;
-       virtual std::string dump(const unsigned int indentLevel = 0) const;
-    };
+        return file;
+    }
+
+    virtual bool isFile() const
+    {
+        return true;
+    }
+
+    virtual std::string getCompletePath() const;
+
+    const std::string & getFileName() const
+    {
+        return filename;
+    }
+
+    const std::string & getRootPath() const
+    {
+        return path;
+    }
+
+    hsize_t getFileSize() const;
+    void getFileHDF5Version(unsigned int * out) const;
+
+    virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const;
+
+    virtual std::string toString(const unsigned int indentLevel) const;
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const;
+    virtual std::string ls() const;
+
+    static bool checkFileAccess(const std::string & access)
+    {
+        return access == "r" || access == "r+" || access == "w" || access == "w-" || access == "a";
+    }
+
+private :
+
+    void init();
+
+    static FileAccess getFlags(const std::string & access)
+    {
+        if (access == "r")
+        {
+            return RDONLY;
+        }
+        else if (access == "r+")
+        {
+            return RDWR;
+        }
+        else if (access == "w")
+        {
+            return TRUNC;
+        }
+        else if (access == "w-")
+        {
+            return EXCL;
+        }
+
+        return APPEND;
+    }
+
+};
 }
 
 #endif // __H5FILE_HXX__
index 7b06f27..6cd8b1d 100644 (file)
 namespace org_modules_hdf5
 {
 
-    class H5FloatData : public H5Data
-    {
+class H5FloatData : public H5Data
+{
 
-    protected:
+protected:
 
-        double * transformedData;
+    double * transformedData;
 
-    public:
-       
-       H5FloatData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, float * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
-           {
-               transformedData = new double[totalSize];
+public:
 
-               if (stride == -1)
-               { 
-                   for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
-                   {
-                       transformedData[i] = (double)(_data[i]); 
-                   }
-               }
-               else
-               {
-                   char * __data = (char *)_data;
-                   for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
-                   {
-                       transformedData[i] = (double)(*((float *)(__data + offset)));
-                       __data += stride;
-                   }
-               }
-           }
+    H5FloatData(H5Object & _parent, const hsize_t _totalSize, const hsize_t _dataSize, const hsize_t _ndims, const hsize_t * _dims, float * _data, const hsize_t _stride = -1, const size_t _offset = 0, const bool _dataOwner = true) : H5Data(_parent, _totalSize, _dataSize, _ndims, _dims, _data, _stride, _offset, _dataOwner)
+    {
+        transformedData = new double[totalSize];
 
-       virtual ~H5FloatData()
-           {
-               delete[] transformedData;
-           }
+        if (stride == -1)
+        {
+            for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
+            {
+                transformedData[i] = (double)(_data[i]);
+            }
+        }
+        else
+        {
+            char * __data = (char *)_data;
+            for (unsigned int i = 0; i < (unsigned int)totalSize; i++)
+            {
+                transformedData[i] = (double)(*((float *)(__data + offset)));
+                __data += stride;
+            }
+        }
+    }
 
-       virtual void * getData() const
-           {
-               return transformedData;
-           }
+    virtual ~H5FloatData()
+    {
+        delete[] transformedData;
+    }
 
-        virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+    virtual void * getData() const
+    {
+        return transformedData;
+    }
+
+    virtual void printData(std::ostream & os, const unsigned int pos, const unsigned int indentLevel) const
+    {
+        os << transformedData[pos];
+    }
+
+    virtual void toScilab(void * pvApiCtx, const int lhsPosition, int * parentList = 0, const int listPosition = 0) const
+    {
+        SciErr err;
+        double * newData = 0;
+        if (ndims == 1)
+        {
+            H5BasicData<char>::alloc(pvApiCtx, lhsPosition, 1, *dims, parentList, listPosition, &newData);
+            memcpy(static_cast<void *>(newData), static_cast<void *>(transformedData), totalSize * sizeof(double));
+        }
+        else
+        {
+            if (ndims == 2)
             {
-               SciErr err;
-                double * newData = 0;
-                if (ndims == 1)
-                {
-                    H5BasicData<char>::alloc(pvApiCtx, lhsPosition, 1, *dims, parentList, listPosition, &newData);
-                    memcpy(static_cast<void *>(newData), static_cast<void *>(transformedData), totalSize * sizeof(double));
-                }
-                else
-                {
-                    if (ndims == 2)
-                    {
-                        H5BasicData<char>::alloc(pvApiCtx, lhsPosition, dims[0], dims[1], parentList, listPosition, &newData);
-                        H5DataConverter::C2FHypermatrix(2, dims, 0, static_cast<double *>(getData()), newData);
-                    }
-                    else
-                    {
-                        int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
-                       H5BasicData<char>::alloc(pvApiCtx, lhsPosition, 1, totalSize, list, 3, &newData);
-                        H5DataConverter::C2FHypermatrix(ndims, dims, totalSize, static_cast<double *>(getData()), newData);
-                    }
-                }
+                H5BasicData<char>::alloc(pvApiCtx, lhsPosition, dims[0], dims[1], parentList, listPosition, &newData);
+                H5DataConverter::C2FHypermatrix(2, dims, 0, static_cast<double *>(getData()), newData);
             }
-
-        virtual std::string dump(const unsigned int indentLevel) const
+            else
             {
-               return H5DataConverter::dump(indentLevel, ndims, dims, static_cast<double *>(getData()), *this);
-           }
-    };
+                int * list = getHypermatrix(pvApiCtx, lhsPosition, parentList, listPosition);
+                H5BasicData<char>::alloc(pvApiCtx, lhsPosition, 1, totalSize, list, 3, &newData);
+                H5DataConverter::C2FHypermatrix(ndims, dims, totalSize, static_cast<double *>(getData()), newData);
+            }
+        }
+    }
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+    {
+        return H5DataConverter::dump(alreadyVisited, indentLevel, ndims, dims, *this);
+    }
+};
 }
 
 #endif // __H5FLOATDATA_HXX__
index 74edbef..7368d22 100644 (file)
 
 #include "H5Group.hxx"
 #include "H5File.hxx"
+#include "H5SoftLinksList.hxx"
 #include "H5LinksList.hxx"
 #include "H5GroupsList.hxx"
 #include "H5DatasetsList.hxx"
 #include "H5TypesList.hxx"
+#include "H5Link.hxx"
 
 namespace org_modules_hdf5
 {
 
-    H5Group::H5Group(H5Object & _parent, const char * _name) : H5Object(_parent), name(_name)
+void H5Group::init()
+{
+    group = H5Gopen(getParent().getH5Id(), name.c_str(), H5P_DEFAULT);
+    if (group < 0)
     {
-       group = H5Gopen(_parent.getH5Id(), name, H5P_DEFAULT);
-       if (group < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot open the group %s."), name);
-       }
+        throw H5Exception(__LINE__, __FILE__, _("Cannot open the group %s."), name.c_str());
     }
+}
+
+H5Group::H5Group(H5Object & _parent, const std::string & _name) : H5Object(_parent), name(_name)
+{
+    init();
+}
+
+H5Group::H5Group(H5Object & _parent, const char * _name) : H5Object(_parent), name(std::string(_name))
+{
+    init();
+}
 
-    H5Group::H5Group(H5Object & _parent, hid_t _group, const char * _name) : H5Object(_parent), group(_group), name(_name)
+H5Group::H5Group(H5Object & _parent, hid_t _group, const char * _name) : H5Object(_parent), group(_group), name(std::string(_name))
+{
+
+}
+
+H5Group::H5Group(H5Object & _parent, hid_t _group, const std::string & _name) : H5Object(_parent), group(_group), name(_name)
+{
+
+}
+
+H5Group::~H5Group()
+{
+    if (group >= 0)
     {
+        H5Gclose(group);
+    }
+}
+
+H5LinksList & H5Group::getLinks()
+{
+    return *new H5LinksList(*this);
+}
+
+H5NamedObjectsList<H5SoftLink> & H5Group::getSoftLinks()
+{
+    return *new H5NamedObjectsList<H5SoftLink>(*this, -1, H5L_TYPE_SOFT, "Soft Link");
+}
+
+H5NamedObjectsList<H5ExternalLink> & H5Group::getExternalLinks()
+{
+    return *new H5NamedObjectsList<H5ExternalLink>(*this, -1, H5L_TYPE_EXTERNAL, "External Link");
+}
+
+H5GroupsList & H5Group::getGroups()
+{
+    return *new H5GroupsList(*this);
+}
+
+H5NamedObjectsList<H5Group> & H5Group::getHardGroups()
+{
+    return *new H5NamedObjectsList<H5Group>(*this, H5O_TYPE_GROUP, H5L_TYPE_HARD, "Group");
+}
+
+H5NamedObjectsList<H5Type> & H5Group::getHardTypes()
+{
+    return *new H5NamedObjectsList<H5Type>(*this, H5O_TYPE_NAMED_DATATYPE, H5L_TYPE_HARD, "Type");
+}
 
+H5NamedObjectsList<H5Dataset> & H5Group::getHardDatasets()
+{
+    return *new H5NamedObjectsList<H5Dataset>(*this, H5O_TYPE_DATASET, H5L_TYPE_HARD, "Dataset");
+}
+
+H5DatasetsList & H5Group::getDatasets()
+{
+    return *new H5DatasetsList(*this);
+}
+
+H5TypesList & H5Group::getTypes()
+{
+    return *new H5TypesList(*this);
+}
+
+const unsigned int H5Group::getLinksSize() const
+{
+    herr_t err;
+    H5G_info_t info;
+
+    err = H5Gget_info(group, &info);
+    if (err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the links number"));
     }
 
-    H5Group::~H5Group()
+    return (unsigned int)info.nlinks;
+}
+
+std::string H5Group::getCompletePath() const
+{
+    std::string name = getName();
+    if (name == "/")
     {
-       if (group >= 0)
-       {
-           H5Gclose(group);
-       }
-       if (name)
-       {
-           FREE(const_cast<char *>(name));
-       }
+        return "/";
     }
 
-    H5LinksList & H5Group::getLinks()
+    return H5Object::getCompletePath();
+}
+
+void H5Group::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    SciErr err;
+    std::string lower(_name);
+
+    try
     {
-       return *new H5LinksList(*this);
+        H5Object & obj = H5Object::getObject(*const_cast<H5Group *>(this), _name);
+        obj.createOnScilabStack(pos, pvApiCtx);
+        return;
     }
+    catch (H5Exception & e) { }
+
+    std::transform(_name.begin(), _name.end(), lower.begin(), tolower);
 
-    H5GroupsList & H5Group::getGroups()
+    if (lower == "attributes")
     {
-       return *new H5GroupsList(*this);
+        const H5AttributesList & attrs = const_cast<H5Group *>(this)->getAttributes();
+        attrs.createOnScilabStack(pos, pvApiCtx);
+
+        return;
     }
+    else if (lower == "groups")
+    {
+        const H5GroupsList & groups = const_cast<H5Group *>(this)->getGroups();
+        groups.createOnScilabStack(pos, pvApiCtx);
 
-    H5DatasetsList & H5Group::getDatasets()
+        return;
+    }
+    else if (lower == "datasets")
     {
-       return *new H5DatasetsList(*this);
+        const H5DatasetsList & sets = const_cast<H5Group *>(this)->getDatasets();
+        sets.createOnScilabStack(pos, pvApiCtx);
+
+        return;
     }
+    else if (lower == "types")
+    {
+        const H5TypesList & types = const_cast<H5Group *>(this)->getTypes();
+        types.createOnScilabStack(pos, pvApiCtx);
 
-    H5TypesList & H5Group::getTypes()
+        return;
+    }
+    else if (lower == "links")
     {
-       return *new H5TypesList(*this);
+        std::vector<std::string> names;
+        std::vector<std::string> types;
+        std::vector<std::string> linkstype;
+        std::vector<const char *> _str;
+        H5Object::getLinksInfo(*this, names, types, linkstype);
+        _str.reserve(names.size() * 3);
+
+        for (unsigned int i = 0; i < names.size(); i++)
+        {
+            _str.push_back(names[i].c_str());
+        }
+        for (unsigned int i = 0; i < names.size(); i++)
+        {
+            _str.push_back(linkstype[i].c_str());
+        }
+        for (unsigned int i = 0; i < names.size(); i++)
+        {
+            _str.push_back(types[i].c_str());
+        }
+
+        err = createMatrixOfString(pvApiCtx, pos, names.size(), 3, &(_str[0]));
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a column of strings on the stack."));
+        }
+
+        return;
     }
 
-    std::string H5Group::dump(const unsigned int indentLevel) const
+    H5Object::getAccessibleAttribute(_name, pos, pvApiCtx);
+}
+
+std::string H5Group::ls() const
+{
+    std::ostringstream os;
+    herr_t err;
+    OpData opdata;
+    opdata.parent = const_cast<H5Group *>(this);
+    opdata.os = &os;
+    hsize_t idx = 0;
+
+    err = H5Literate(group, H5_INDEX_NAME, H5_ITER_INC, &idx, printLsInfo, &opdata);
+    if (err < 0)
     {
-       std::ostringstream os;
-       H5AttributesList & attrs = const_cast<H5Group *>(this)->getAttributes();
-       H5LinksList & links = const_cast<H5Group *>(this)->getLinks();
-       
-       os << H5Object::getIndentString(indentLevel) << "GROUP \"" << name << "\" {" << std::endl
-          << attrs.dump(indentLevel + 1)
-          << links.dump(indentLevel + 1)
-          << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot list group contents"));
+    }
 
-       delete &attrs;
-       delete &links;
+    return os.str();
+}
 
-       return os.str();
+herr_t H5Group::printLsInfo(hid_t g_id, const char * name, const H5L_info_t * info, void * op_data)
+{
+    H5O_info_t oinfo;
+    herr_t err;
+    H5Object * hobj = 0;
+    hid_t obj;
+    OpData & opdata = *(OpData *)op_data;
+
+    if (obj < 0)
+    {
+        return (herr_t) - 1;
     }
 
-    std::string H5Group::toString(const unsigned int indentLevel) const
+    switch (info->type)
     {
-       std::ostringstream os;
-       std::string indentString = H5Object::getIndentString(indentLevel);
-       const H5GroupsList & groups = const_cast<H5Group *>(this)->getGroups();
-       const H5DatasetsList & datasets = const_cast<H5Group *>(this)->getDatasets();
-       const H5TypesList & types = const_cast<H5Group *>(this)->getTypes();
-       const H5AttributesList & attrs = const_cast<H5Group *>(this)->getAttributes();
-       
-       os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
-          << indentString << _("Group name") << ": " << name << std::endl
-          << indentString << _("Group path") << ": " << getCompletePath() << std::endl
-          << indentString << _("Number of attributes") << ": " << attrs.getSize() << std::endl
-          << indentString << _("Number of named groups") << ": " << groups.getSize() << std::endl
-          << indentString << _("Number of named datasets") << ": " << datasets.getSize() << std::endl
-          << indentString << _("Number of named types") << ": " << types.getSize();
+        case H5L_TYPE_SOFT:
+            hobj = new H5SoftLink(*opdata.parent, name);
+            break;
+        case H5L_TYPE_EXTERNAL:
+            hobj = new H5ExternalLink(*opdata.parent, name);
+            break;
+        case H5L_TYPE_HARD:
+            obj = H5Oopen(g_id, name, H5P_DEFAULT);
+            err = H5Oget_info(obj, &oinfo);
+            H5Oclose(obj);
+
+            if (err < 0)
+            {
+                return (herr_t) - 1;
+            }
+
+            switch (oinfo.type)
+            {
+                case H5O_TYPE_GROUP:
+                    hobj = new H5Group(*opdata.parent, name);
+                    break;
+                case H5O_TYPE_DATASET:
+                    hobj = new H5Dataset(*opdata.parent, name);
+                    break;
+                case H5O_TYPE_NAMED_DATATYPE:
+                    hobj = new H5Type(*opdata.parent, name);
+                    break;
+                default:
+                    return (herr_t) - 1;
+            }
+            break;
+        default:
+            return (herr_t) - 1;
+    }
+
+    hobj->printLsInfo(*opdata.os);
+    delete hobj;
+
+    return (herr_t)0;
+}
+
+void H5Group::printLsInfo(std::ostringstream & os) const
+{
+    std::string str(getName());
+    H5Object::getResizedString(str);
 
-       delete &groups;
-       delete &datasets;
-       delete &types;
-       delete &attrs;
+    os << str << "Group" << std::endl;
+}
+
+std::string H5Group::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    haddr_t addr = this->getAddr();
+    std::map<haddr_t, std::string>::iterator it = alreadyVisited.find(addr);
+    if (it != alreadyVisited.end())
+    {
+        os << H5Object::getIndentString(indentLevel) << "GROUP \"" << getName() << "\" {" << std::endl
+           << H5Object::getIndentString(indentLevel + 1) << "HARDLINK \"" << it->second << "\"" << std::endl
+           << H5Object::getIndentString(indentLevel) << "}" << std::endl;
 
-       return os.str();
+        return os.str();
     }
+    else
+    {
+        alreadyVisited.insert(std::pair<haddr_t, std::string>(addr, getCompletePath()));
+    }
+
+    H5AttributesList & attrs = const_cast<H5Group *>(this)->getAttributes();
+    H5NamedObjectsList<H5SoftLink> & softlinks = const_cast<H5Group *>(this)->getSoftLinks();
+    H5NamedObjectsList<H5ExternalLink> & externallinks = const_cast<H5Group *>(this)->getExternalLinks();
+    H5NamedObjectsList<H5Group> & hardgroups = const_cast<H5Group *>(this)->getHardGroups();
+    H5NamedObjectsList<H5Type> & hardtypes = const_cast<H5Group *>(this)->getHardTypes();
+    H5NamedObjectsList<H5Dataset> & harddatasets = const_cast<H5Group *>(this)->getHardDatasets();
+
+    os << H5Object::getIndentString(indentLevel) << "GROUP \"" << name << "\" {" << std::endl;
+    os << attrs.dump(alreadyVisited, indentLevel + 1);
+    os << hardgroups.dump(alreadyVisited, indentLevel + 1);
+    os << hardtypes.dump(alreadyVisited, indentLevel + 1);
+    os << harddatasets.dump(alreadyVisited, indentLevel + 1);
+    os << softlinks.dump(alreadyVisited, indentLevel + 1);
+    os << externallinks.dump(alreadyVisited, indentLevel + 1);
+    os << H5Object::getIndentString(indentLevel) << "}" << std::endl;
+
+    delete &attrs;
+    delete &softlinks;
+    delete &externallinks;
+    delete &hardgroups;
+    delete &hardtypes;
+    delete &harddatasets;
+
+    return os.str();
+}
+
+std::string H5Group::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel + 1);
+    const H5GroupsList & groups = const_cast<H5Group *>(this)->getGroups();
+    const H5DatasetsList & datasets = const_cast<H5Group *>(this)->getDatasets();
+    const H5TypesList & types = const_cast<H5Group *>(this)->getTypes();
+    const H5AttributesList & attrs = const_cast<H5Group *>(this)->getAttributes();
+
+    os << H5Object::getIndentString(indentLevel) << "HDF5 Group" << std::endl
+       << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+       << indentString << _("Name") << ": " << getName() << std::endl
+       << indentString << _("Path") << ": " << getCompletePath() << std::endl
+       << indentString << _("Attributes") << ": [1 x " << attrs.getSize() << "]" << std::endl
+       << indentString << _("Groups") << ": [1 x " << groups.getSize() << "]" << std::endl
+       << indentString << _("Datasets") << ": [1 x " << datasets.getSize() << "]" << std::endl
+       << indentString << _("Types") << ": [1 x " << types.getSize() << "]" << std::endl
+       << indentString << _("Links") << ": [" << getLinksSize() << " x 3]";
+
+    delete &groups;
+    delete &datasets;
+    delete &types;
+    delete &attrs;
+
+    return os.str();
+}
+
+H5Group & H5Group::createGroup(H5Object & parent, const std::string & name)
+{
+    hid_t obj;
+    H5Object * loc = 0;
+
+    if (H5Lexists(parent.getH5Id(), name.c_str(), H5P_DEFAULT) > 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("The group already exists: %s."), name.c_str());
+    }
+
+    if (parent.isFile())
+    {
+        loc = &reinterpret_cast<H5File *>(&parent)->getRoot();
+    }
+    else
+    {
+        loc = &parent;
+    }
+
+    obj = H5Gcreate2(loc->getH5Id(), name.c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+    if (obj < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot create the group: %s."), name.c_str());
+    }
+
+    return *new H5Group(*loc, obj, name);
+}
 }
index 2ec20e2..dec382f 100644 (file)
 #define __H5GROUP_HXX__
 
 #include "H5Object.hxx"
+#include "H5Type.hxx"
+#include "H5Dataset.hxx"
+#include "H5SoftLink.hxx"
+#include "H5ExternalLink.hxx"
+#include "H5NamedObjectsList.hxx"
 #include "H5AttributesList.hxx"
 
 namespace org_modules_hdf5
 {
-    
-    class H5LinksList;
-    class H5GroupsList;
-    class H5DatasetsList;
-    class H5TypesList;
-    class H5File;
-
-    class H5Group : public H5Object
+
+class H5SoftLinksList;
+class H5LinksList;
+class H5GroupsList;
+class H5DatasetsList;
+class H5TypesList;
+class H5File;
+
+class H5Group : public H5Object
+{
+    typedef struct
+    {
+        H5Object * parent;
+        std::ostringstream * os;
+    } OpData;
+
+    hid_t group;
+    const std::string name;
+
+public:
+
+    H5Group(H5Object & _parent, const char * name);
+    H5Group(H5Object & _parent, const std::string & name);
+    H5Group(H5Object & _parent, hid_t _group, const char * _name);
+    H5Group(H5Object & _parent, hid_t _group, const std::string & _name);
+
+    virtual ~H5Group();
+
+    virtual hid_t getH5Id() const
     {
-       hid_t group;
-       const char * name;
-
-    public:
-
-       H5Group(H5Object & _parent, const char * name);
-       H5Group(H5Object & _parent, hid_t _group, const char * _name);
-       
-       virtual ~H5Group();
-
-       virtual hid_t getH5Id() const { return group; }
-        virtual H5LinksList & getLinks();
-        virtual H5GroupsList & getGroups();
-        virtual H5DatasetsList & getDatasets();
-        virtual H5TypesList & getTypes();
-       virtual std::string getName() const { return std::string(name); }
-       virtual std::string toString(const unsigned int indentLevel) const;
-       virtual std::string dump(const unsigned int indentLevel = 0) const;
-    };
+        return group;
+    }
+
+    virtual bool checkType(const int type) const
+    {
+        return type == H5O_TYPE_GROUP;
+    }
+
+    virtual H5LinksList & getLinks();
+    virtual H5NamedObjectsList<H5SoftLink> & getSoftLinks();
+    virtual H5NamedObjectsList<H5ExternalLink> & getExternalLinks();
+    virtual H5GroupsList & getGroups();
+    virtual H5NamedObjectsList<H5Group> & getHardGroups();
+    virtual H5NamedObjectsList<H5Type> & getHardTypes();
+    virtual H5NamedObjectsList<H5Dataset> & getHardDatasets();
+    virtual H5DatasetsList & getDatasets();
+    virtual H5TypesList & getTypes();
+    const unsigned int getLinksSize() const;
+    virtual std::string getCompletePath() const;
+    virtual const std::string & getName() const
+    {
+        return name;
+    }
+    virtual std::string toString(const unsigned int indentLevel) const;
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const;
+    virtual std::string ls() const;
+    virtual void printLsInfo(std::ostringstream & os) const;
+
+    virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const;
+
+    static H5Group & createGroup(H5Object & parent, const std::string & name);
+
+private :
+
+    void init();
+    static herr_t printLsInfo(hid_t g_id, const char * name, const H5L_info_t * info, void * op_data);
+};
 }
 
 #endif // __H5GROUP_HXX__
index 847832e..4e54ad2 100644 (file)
 
 namespace org_modules_hdf5
 {
-    H5GroupsList::H5GroupsList(H5Object & _parent) : H5ListObject(_parent) { }
+H5GroupsList::H5GroupsList(H5Object & _parent) : H5ListObject(_parent) { }
 
-    H5GroupsList::~H5GroupsList() { }
-    
-    const unsigned int H5GroupsList::getSize() const
+H5GroupsList::~H5GroupsList() { }
+
+const unsigned int H5GroupsList::getSize() const
+{
+    H5G_info_t info;
+    hsize_t count = 0;
+    hid_t parentId = getParent().getH5Id();
+    herr_t err = H5Gget_info(parentId, &info);
+
+    if (err < 0)
     {
-       H5G_info_t info;
-       hsize_t count = 0;
-       hid_t parentId = getParent().getH5Id();
-       herr_t err = H5Gget_info(parentId, &info);
-       
-       if (err < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
-       }
-       
-       for (hsize_t i = 0; i < info.nlinks; i++)
-       {
-           int type = H5Gget_objtype_by_idx(parentId, i);
-           if (type == H5G_GROUP)
-           {
-               count++;
-           }
-       }
-       
-       return (unsigned int)count;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
     }
 
-    void H5GroupsList::setObject(const unsigned int pos, H5Group & obj)
+    for (hsize_t i = 0; i < info.nlinks; i++)
     {
-
+        int type = H5Gget_objtype_by_idx(parentId, i);
+        if (type == H5G_GROUP)
+        {
+            count++;
+        }
     }
 
-    H5Group & H5GroupsList::getObject(const int pos)
+    return (unsigned int)count;
+}
+
+void H5GroupsList::setObject(const unsigned int pos, H5Group & obj)
+{
+
+}
+
+H5Group & H5GroupsList::getObject(const int pos)
+{
+    return getObject(pos, true);
+}
+
+H5Group & H5GroupsList::getObject(const int pos, const bool checkPos)
+{
+    int type;
+    herr_t err;
+    hsize_t count = 0;
+    hsize_t index = 0;
+    hid_t parentId = getParent().getH5Id();
+    ssize_t nameSize;
+    char * name = 0;
+
+    if (checkPos)
     {
-       return getObject(pos, true);
+        unsigned int size = getSize();
+        if (pos < 0 || pos >= size)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
+        }
     }
 
-    H5Group & H5GroupsList::getObject(const int pos, const bool checkPos)
+    err = H5Gget_info(parentId, &info);
+    if (err < 0)
     {
-       int type;
-       herr_t err;
-       hsize_t count = 0;
-       hsize_t index = 0;
-       hid_t parentId = getParent().getH5Id();
-       ssize_t nameSize;
-       char * name = 0;
-
-       if (checkPos)
-       {
-           unsigned int size = getSize();
-           if (pos < 0 || pos >= size)
-           {
-               throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
-           }
-       }
-
-       err = H5Gget_info(parentId, &info);
-       if (err < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
-       }
-       
-       for (; index < info.nlinks; index++)
-       {
-           int type = H5Gget_objtype_by_idx(parentId, index);
-           if (type == H5G_GROUP)
-           {
-               count++;
-               if (count == pos)
-               {
-                   break;
-               }
-           }
-       }
-           
-       nameSize = H5Gget_objname_by_idx(parentId, index, 0, 0);
-       name = (char *)MALLOC((nameSize + 1) * sizeof(char));
-       H5Gget_objname_by_idx(parentId, index, name, nameSize + 1);
-       
-       return *new H5Group(getParent(), name);
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
     }
 
-    std::string H5GroupsList::dump(const unsigned int indentLevel) const
+    for (; index < info.nlinks; index++)
     {
-       std::ostringstream os;
-       const unsigned int size = getSize();
-
-       for (unsigned int i = 0; i < size; i++)
-       {
-           const H5Group & group = const_cast<H5GroupsList *>(this)->getObject(i, false);
-           os << group.toString(indentLevel) << std::endl;
-
-           delete &group;
-       }
-       
-       return os.str();
+        int type = H5Gget_objtype_by_idx(parentId, index);
+        if (type == H5G_GROUP)
+        {
+            count++;
+            if (count == pos)
+            {
+                break;
+            }
+        }
     }
 
-    std::string H5GroupsList::toString(const unsigned int indentLevel) const
+    nameSize = H5Gget_objname_by_idx(parentId, index, 0, 0);
+    name = (char *)MALLOC((nameSize + 1) * sizeof(char));
+    H5Gget_objname_by_idx(parentId, index, name, nameSize + 1);
+
+    return *new H5Group(getParent(), name);
+}
+
+std::string H5GroupsList::dump(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    const unsigned int size = getSize();
+
+    for (unsigned int i = 0; i < size; i++)
     {
+        const H5Group & group = const_cast<H5GroupsList *>(this)->getObject(i, false);
+        os << group.toString(indentLevel) << std::endl;
 
+        delete &group;
     }
+
+    return os.str();
+}
+
+std::string H5GroupsList::toString(const unsigned int indentLevel) const
+{
+
+}
 }
index 0fc083b..da7359b 100644 (file)
 namespace org_modules_hdf5
 {
 
-    class H5GroupsList : public H5NamedObjectsList<H5Group>
-    {
+class H5GroupsList : public H5NamedObjectsList<H5Group>
+{
+
+public :
 
-    public :
-       
-       H5GroupsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_GROUP, "H5 Group") { }
-       
-       ~H5GroupsList()
-           {
+    H5GroupsList(H5Group & _parent) : H5NamedObjectsList(_parent, H5G_GROUP, -1, "H5 Group") { }
+
+    ~H5GroupsList()
+    {
 
-           }
-    };
+    }
+};
 }
 
 #endif // __H5GROUPSLIST_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5HardLink.cpp b/scilab/modules/hdf5/src/cpp/H5HardLink.cpp
new file mode 100644 (file)
index 0000000..76fa6dd
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Object.hxx"
+#include "H5HardLink.hxx"
+
+namespace org_modules_hdf5
+{
+
+H5Object & H5HardLink::getLinkedObject() const
+{
+    herr_t err;
+    H5L_info_t info;
+    hid_t obj;
+
+    err = H5Lget_info(getParent().getH5Id(), name.c_str(), &info, H5P_DEFAULT);
+    if (err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the link info"));
+    }
+
+    obj = H5Oopen_by_addr(getFile().getH5Id(), info.u.address);
+    if (obj < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get linked object"));
+    }
+
+    try
+    {
+        return H5Object::getObject(*const_cast<H5HardLink *>(this), obj);
+    }
+    catch (H5Exception & e)
+    {
+        H5Oclose(obj);
+        throw;
+    }
+}
+
+std::string H5HardLink::getLinkType() const
+{
+    return "hard";
+}
+
+void H5HardLink::getAccessibleAttribute(const std::string & _name, const int pos, void * pvApiCtx) const
+{
+    SciErr err;
+    std::string lower(_name);
+    std::transform(_name.begin(), _name.end(), lower.begin(), tolower);
+
+    if (lower == "type")
+    {
+        const char * _type = getLinkType().c_str();
+        err = createMatrixOfString(pvApiCtx, pos, 1, 1, &_type);
+        if (err.iErr)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot create a string on the stack."));
+        }
+
+        return;
+    }
+    else if (lower == "target")
+    {
+        H5Object & obj = getLinkedObject();
+        obj.createOnScilabStack(pos, pvApiCtx);
+
+        return;
+    }
+
+    H5Object::getAccessibleAttribute(_name, pos, pvApiCtx);
+}
+
+std::string H5HardLink::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    H5Object & obj = getLinkedObject();
+
+    os << H5Object::getIndentString(indentLevel) << "HARDLINK \"" << obj.getName() << "\"" << std::endl;
+
+    delete &obj;
+
+    return os.str();
+}
+
+std::string H5HardLink::toString(const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    std::string indentString = H5Object::getIndentString(indentLevel);
+    H5Object & obj = getLinkedObject();
+
+    os << indentString << _("Filename") << ": " << getFile().getFileName() << std::endl
+       << indentString << _("Link type") << ": " << getLinkType() << std::endl
+       << indentString << _("Link name") << ": " << name << std::endl
+       << indentString << _("Link path") << ": " << getCompletePath() << std::endl
+       << indentString << _("Link target name") << ": " << obj.getName();
+
+    delete &obj;
+
+    return os.str();
+}
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5HardLink.hxx b/scilab/modules/hdf5/src/cpp/H5HardLink.hxx
new file mode 100644 (file)
index 0000000..2b3f945
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5HARDLINK_HXX__
+#define __H5HARDLINK_HXX__
+
+#include "H5Link.hxx"
+
+namespace org_modules_hdf5
+{
+
+class H5Object;
+
+class H5HardLink : public H5Link
+{
+public:
+
+    H5HardLink(H5Object & _parent, const char * name) : H5Link(_parent, name) { }
+    H5HardLink(H5Object & _parent, const std::string & name) : H5Link(_parent, name) { }
+
+    virtual ~H5HardLink() { }
+
+    virtual std::string toString(const unsigned int indentLevel) const;
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const;
+
+    H5Object & getLinkedObject() const;
+    virtual std::string getLinkType() const;
+
+    virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const;
+};
+}
+
+#endif // __H5HARDLINK_HXX__
diff --git a/scilab/modules/hdf5/src/cpp/H5Link.cpp b/scilab/modules/hdf5/src/cpp/H5Link.cpp
new file mode 100644 (file)
index 0000000..bf70657
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "H5Link.hxx"
+#include "H5SoftLink.hxx"
+#include "H5ExternalLink.hxx"
+#include "H5HardLink.hxx"
+#include "H5Object.hxx"
+
+namespace org_modules_hdf5
+{
+
+H5Link::H5Link(H5Object & _parent, const char * _name) : H5Object(_parent), name(std::string(_name))
+{
+    if (H5Lexists(_parent.getH5Id(), name.c_str(), H5P_DEFAULT) <= 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("The link %s does not exist."), name.c_str());
+    }
+}
+
+H5Link::H5Link(H5Object & _parent, const std::string & _name) : H5Object(_parent), name(_name)
+{
+    if (H5Lexists(_parent.getH5Id(), name.c_str(), H5P_DEFAULT) <= 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("The link %s does not exist."), name.c_str());
+    }
+}
+
+H5Link::~H5Link()
+{
+
+}
+
+H5Link & H5Link::getLink(H5Object & _parent, const std::string & _name)
+{
+    return getLink(_parent, _name.c_str());
+}
+
+H5Link & H5Link::getLink(H5Object & _parent, const char * _name)
+{
+    herr_t err;
+    H5L_info_t info;
+    H5Link * link = 0;
+    err = H5Lget_info(_parent.getH5Id(), _name, &info, H5P_DEFAULT);
+
+    if (err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the link info"));
+    }
+
+    switch (info.type)
+    {
+        case H5L_TYPE_HARD:
+            link = new H5HardLink(_parent, _name);
+            break;
+        case H5L_TYPE_SOFT:
+            link = new H5SoftLink(_parent, _name);
+            break;
+        case H5L_TYPE_EXTERNAL:
+            link = new H5ExternalLink(_parent, _name);
+            break;
+        case H5L_TYPE_ERROR:
+        default:
+            throw H5Exception(__LINE__, __FILE__, _("Invalid link type: %s."), _name);
+    }
+
+    return *link;
+}
+}
diff --git a/scilab/modules/hdf5/src/cpp/H5Link.hxx b/scilab/modules/hdf5/src/cpp/H5Link.hxx
new file mode 100644 (file)
index 0000000..f31af52
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __H5LINK_HXX__
+#define __H5LINK_HXX__
+
+#include "H5Object.hxx"
+#include "H5File.hxx"
+
+namespace org_modules_hdf5
+{
+
+class H5Link : public H5Object
+{
+
+protected:
+
+    const std::string name;
+
+public:
+
+    H5Link(H5Object & _parent, const char * name);
+    H5Link(H5Object & _parent, const std::string & name);
+
+    virtual ~H5Link();
+
+    virtual const std::string & getName() const
+    {
+        return name;
+    }
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel = 0) const
+    {
+        return "";
+    };
+
+    virtual std::string getLinkType() const
+    {
+        return "";
+    }
+
+    static H5Link & getLink(H5Object & _parent, const char * _name);
+    static H5Link & getLink(H5Object & _parent, const std::string & _name);
+};
+}
+
+#endif // __H5LINK_HXX__
index 91dfb6e..f39b450 100644 (file)
 
 namespace org_modules_hdf5
 {
-    H5LinksList::H5LinksList(H5Object & _parent) : H5ListObject(_parent) { }
+H5LinksList::H5LinksList(H5Object & _parent) : H5ListObject(_parent) { }
 
-    H5LinksList::~H5LinksList() { }
-    
-    const unsigned int H5LinksList::getSize() const
+H5LinksList::~H5LinksList() { }
+
+const unsigned int H5LinksList::getSize() const
+{
+    H5G_info_t info;
+    herr_t err = H5Gget_info(getParent().getH5Id(), &info);
+
+    if (err < 0)
     {
-       H5G_info_t info;
-       herr_t err = H5Gget_info(getParent().getH5Id(), &info);
-       
-       if (err < 0)
-       {
-           throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of links."));
-       }
-
-       return (unsigned int)info.nlinks;
+        throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of links."));
     }
 
-    void H5LinksList::setObject(const unsigned int pos, H5Object & obj)
-    {
+    return (unsigned int)info.nlinks;
+}
 
-    }
+void H5LinksList::setObject(const unsigned int pos, H5Object & obj)
+{
 
-    H5Object & H5LinksList::getObject(const int pos)
-    {
-       return getObject(pos, true);
-    }
+}
+
+H5Object & H5LinksList::getObject(const int pos)
+{
+    return getObject(pos, true);
+}
 
-    H5Object & H5LinksList::getObject(const int pos, const bool checkPos)
+H5Object & H5LinksList::getObject(const int pos, const bool checkPos)
+{
+    if (checkPos)
     {
-       if (checkPos)
-       {
-           unsigned int size = getSize();
-           if (pos < 0 || pos >= size)
-           {
-               throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
-           }
-       }
-           
-       H5Object * obj = 0;
-       hid_t parentId = getParent().getH5Id();
-       ssize_t nameSize = H5Gget_objname_by_idx(parentId, (hsize_t)pos, 0, 0);
-       char * name = (char *)MALLOC((nameSize + 1) * sizeof(char));
-       H5Gget_objname_by_idx(parentId, (hsize_t)pos, name, nameSize + 1);
-       int type = H5Gget_objtype_by_idx(parentId, (hsize_t)pos);
-
-       switch (type)
-       {
-       case H5G_LINK:
-           //obj = new H5Link(parent, name);
-           break;
-       case H5G_GROUP:
-           obj = new H5Group(getParent(), name);
-           break;
-       case H5G_DATASET:
-           obj = new H5Dataset(getParent(), name);
-           break;
-       case H5G_TYPE:
-           obj = new H5Type(getParent(), name);
-           break;
-       }
-
-       return *obj;
+        unsigned int size = getSize();
+        if (pos < 0 || pos >= size)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
+        }
     }
 
-    std::string H5LinksList::dump(const unsigned int indentLevel) const
+    H5Object * obj = 0;
+    hid_t parentId = getParent().getH5Id();
+    ssize_t nameSize = H5Gget_objname_by_idx(parentId, (hsize_t)pos, 0, 0);
+    char * name = (char *)MALLOC((nameSize + 1) * sizeof(char));
+    H5Gget_objname_by_idx(parentId, (hsize_t)pos, name, nameSize + 1);
+    int type = H5Gget_objtype_by_idx(parentId, (hsize_t)pos);
+
+    switch (type)
     {
-       std::ostringstream os;
-       const unsigned int size = getSize();
-
-       for (unsigned int i = 0; i < size; i++)
-       {
-           const H5Object & obj = const_cast<H5LinksList *>(this)->getObject(i, false);
-           os << obj.dump(indentLevel);
-
-           delete &obj;
-       }
-       
-       return os.str();
+        case H5G_LINK:
+            obj = &H5Link::getLink(getParent(), name);
+            break;
+        case H5G_GROUP:
+            obj = new H5Group(getParent(), name);
+            break;
+        case H5G_DATASET:
+            obj = new H5Dataset(getParent(), name);
+            break;
+        case H5G_TYPE:
+            obj = new H5Type(getParent(), name);
+            break;
     }
 
-    std::string H5LinksList::toString(const unsigned int indentLevel) const
+    return *obj;
+}
+
+std::string H5LinksList::dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const
+{
+    std::ostringstream os;
+    const unsigned int size = getSize();
+
+    for (unsigned int i = 0; i < size; i++)
     {
-       return "";
+        const H5Object & obj = const_cast<H5LinksList *>(this)->getObject(i, false);
+        os << obj.dump(alreadyVisited, indentLevel);
+
+        delete &obj;
     }
+
+    return os.str();
+}
+
+std::string H5LinksList::toString(const unsigned int indentLevel) const
+{
+    return "";
+}
 }
index 5cdb80d..bac12c0 100644 (file)
 #include "H5Group.hxx"
 #include "H5Dataset.hxx"
 #include "H5Type.hxx"
+#include "H5Link.hxx"
 
 namespace org_modules_hdf5
 {
-    class H5Attribute;
+class H5Attribute;
 
-    class H5LinksList : public H5ListObject<H5Object>
-    {
+class H5LinksList : public H5ListObject<H5Object>
+{
+
+public :
+
+    H5LinksList(H5Object & _parent);
+
+    ~H5LinksList();
 
-    public :
-       
-       H5LinksList(H5Object & _parent);
-       
-       ~H5LinksList();
+    void setObject(const unsigned int pos, H5Object & obj);
+    H5Object & getObject(const int pos);
+    const unsigned int getSize() const;
 
-       void setObject(const unsigned int pos, H5Object & obj);
-       H5Object & getObject(const int pos);
-       const unsigned int getSize() const;
-       
-       virtual std::string dump(const unsigned int indentLevel) const;
-        virtual std::string toString(const unsigned int indentLevel) const;
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const unsigned int indentLevel) const;
+    virtual std::string toString(const unsigned int indentLevel) const;
 
-    private:
+private:
 
-       H5Object & getObject(const int pos, const bool checkPos);
-    };
+    H5Object & getObject(const int pos, const bool checkPos);
+};
 }
 
 #endif // __H5LINKSLIST_HXX__
index 9f17cb4..5c5ff3d 100644 (file)
 namespace org_modules_hdf5
 {
 
-    template<typename T>
-    class H5ListObject : public H5Object
+template<typename T>
+class H5ListObject : public H5Object
+{
+
+public :
+
+    H5ListObject(H5Object & _parent) : H5Object(_parent) { }
+
+    virtual void setObject(const unsigned int pos, T & object) = 0;
+    virtual T & getObject(const int pos) = 0;
+    virtual T & getObject(const std::string & name)
     {
+        throw H5Exception(__LINE__, __FILE__, _("Invalid operation"));
+    }
 
-    public :
+    virtual const unsigned int getSize() const = 0;
 
-       H5ListObject(H5Object & _parent) : H5Object(_parent) { }
+    virtual void getAccessibleAttribute(const double index, const int pos, void * pvApiCtx) const
+    {
+        T & obj = const_cast<H5ListObject *>(this)->getObject((int)index);
+        obj.createOnScilabStack(pos, pvApiCtx);
+    }
 
-        virtual void setObject(const unsigned int pos, T & object) = 0;
-        virtual T & getObject(const int pos) = 0;
-        virtual const unsigned int getSize() const = 0;
-    };
+    virtual void getAccessibleAttribute(const std::string & name, const int pos, void * pvApiCtx) const
+    {
+        T & obj = const_cast<H5ListObject *>(this)->getObject(name);
+        obj.createOnScilabStack(pos, pvApiCtx);
+    }
+};
 }
 
 #endif // __H5FILE_HXX__
index 2ac3f64..b56aed6 100644 (file)
 
 #include "H5Object.hxx"
 #include "H5File.hxx"
+#include "H5Link.hxx"
 #include "H5ListObject.hxx"
 
 namespace org_modules_hdf5
 {
 
-    class H5Group;
+class H5Group;
 
-    template <typename T>
-    class H5NamedObjectsList : public H5ListObject<T>
+template <typename T>
+class H5NamedObjectsList : public H5ListObject<T>
+{
+
+    typedef struct
     {
+        union
+        {
+            unsigned int count;
+            const char * name;
+        } u;
+        int linktype;
+        int basetype;
+    } OpData;
 
-    public :
+    int prevPos;
+    hsize_t idx;
 
-        H5NamedObjectsList(H5Group & _parent, const int _baseType, const std::string _baseTypeName) : H5ListObject<T>(_parent), baseType(_baseType), baseTypeName(_baseTypeName) { }
+public :
 
-        virtual ~H5NamedObjectsList()
-            {
+    H5NamedObjectsList(H5Group & _parent, const int _baseType, const int _linkType, const std::string _baseTypeName) : H5ListObject<T>(_parent), baseType(_baseType), linkType(_linkType), baseTypeName(_baseTypeName), prevPos(0), idx(0) { }
 
-            }
+    virtual ~H5NamedObjectsList()
+    {
 
-        void setObject(const unsigned int pos, T & obj)
-            {
+    }
 
-            }
+    void setObject(const unsigned int pos, T & obj)
+    {
 
-        T & getObject(const int pos)
-            {
-                return getObject(pos, true);
-            }
+    }
+
+    T & getObject(const int pos)
+    {
+        return getObject(pos, true);
+    }
 
-        const unsigned int getSize() const
+    inline static herr_t count(hid_t g_id, const char * name, const H5L_info_t * info, void * op_data)
+    {
+        OpData & opdata = *(OpData *)op_data;
+
+        if ((opdata.linktype != -1 && info->type == opdata.linktype) || (opdata.linktype == -1 && info->type != H5L_TYPE_ERROR))
+        {
+            H5O_info_t oinfo;
+            herr_t err;
+            if (opdata.basetype != -1)
             {
-                H5G_info_t info;
-                hsize_t count = 0;
-                hid_t parentId = H5Object::getParent().getH5Id();
-                herr_t err = H5Gget_info(parentId, &info);
+                hid_t obj = H5Oopen(g_id, name, H5P_DEFAULT);
 
-                if (err < 0)
+                if (obj < 0)
                 {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
+                    return (herr_t) - 1;
                 }
 
-                for (hsize_t i = 0; i < info.nlinks; i++)
+                err = H5Oget_info(obj, &oinfo);
+                H5Oclose(obj);
+
+                if (err < 0)
                 {
-                    int type = H5Gget_objtype_by_idx(parentId, i);
-                    if (type == baseType)
-                    {
-                        count++;
-                    }
+                    return (herr_t) - 2;
                 }
 
-                return (unsigned int)count;
-            }
-
-        std::string dump(const unsigned int indentLevel) const
-            {
-                std::ostringstream os;
-                const unsigned int size = getSize();
-               
-                for (unsigned int i = 0; i < size; i++)
+                if (oinfo.type == opdata.basetype)
                 {
-                    const T & obj = const_cast<H5NamedObjectsList *>(this)->getObject(i, false);
-                    os << obj.toString(indentLevel) << std::endl;
-
-                    delete &obj;
+                    opdata.u.count++;
                 }
-
-                return os.str();
             }
-
-        virtual std::string toString(const unsigned int indentLevel) const
+            else
             {
-                std::ostringstream os;
-               std::string indentString = H5Object::getIndentString(indentLevel);
-                const unsigned int size = getSize();
-
-                os << indentString << _("Filename") << ": " << H5Object::getParent().getFile().getFileName() << std::endl
-                   << indentString << _("Parent group name") << ": " << H5Object::getParent().getName() << std::endl
-                   << indentString << _("Parent group path") << ": " << H5Object::getParent().getCompletePath() << std::endl
-                   << indentString << _("Elements type") << ": " << baseTypeName << std::endl
-                   << indentString << _("Number of elements") << ": " << size;
-
-                return os.str();
+                opdata.u.count++;
             }
+        }
 
-    protected :
+        return (herr_t)0;
+    }
 
-        const int baseType;
-        const std::string baseTypeName;
-
-    private:
+    inline static herr_t getElement(hid_t g_id, const char * name, const H5L_info_t * info, void * op_data)
+    {
+        OpData & opdata = *(OpData *)op_data;
 
-        T & getObject(const int pos, const bool checkPos)
+        if ((opdata.linktype != -1 && info->type == opdata.linktype) || (opdata.linktype == -1 && info->type != H5L_TYPE_ERROR))
+        {
+            H5O_info_t oinfo;
+            herr_t err;
+            if (opdata.basetype != -1)
             {
-                int type;
-                herr_t err;
-                hsize_t count = 0;
-                hsize_t index = 0;
-                hid_t parentId = H5Object::getParent().getH5Id();
-               H5G_info_t info;
-                ssize_t nameSize;
-                char * name = 0;
-
-                if (checkPos)
+                hid_t obj = H5Oopen(g_id, name, H5P_DEFAULT);
+
+                if (obj < 0)
                 {
-                    unsigned int size = getSize();
-                    if (pos < 0 || pos >= size)
-                    {
-                        throw H5Exception(__LINE__, __FILE__, _("Invalid index %u: must be between 0 and %u."), pos, size);
-                    }
+                    return (herr_t) - 1;
                 }
 
-                err = H5Gget_info(parentId, &info);
+                err = H5Oget_info(obj, &oinfo);
+                H5Oclose(obj);
+
                 if (err < 0)
                 {
-                    throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups."));
+                    return (herr_t) - 2;
                 }
 
-                for (; index < info.nlinks; index++)
+                if (oinfo.type == opdata.basetype)
                 {
-                    int type = H5Gget_objtype_by_idx(parentId, index);
-                    if (type == baseType)
-                    {
-                        count++;
-                        if (count == pos)
-                        {
-                            break;
-                        }
-                    }
+                    opdata.u.count--;
                 }
+            }
+            else
+            {
+                opdata.u.count--;
+            }
 
-                nameSize = H5Gget_objname_by_idx(parentId, index, 0, 0);
-                name = (char *)MALLOC((nameSize + 1) * sizeof(char));
-                H5Gget_objname_by_idx(parentId, index, name, nameSize + 1);
+            if (opdata.u.count == 0)
+            {
+                opdata.u.name = strdup(name);
 
-                return *new T(H5Object::getParent(), name);
+                return (herr_t)1;
             }
-    };
+        }
+
+        return (herr_t)0;
+    }
+
+    const unsigned int getSize() const
+    {
+        hsize_t idx = 0;
+        OpData op_data;
+        herr_t err;
+
+        op_data.u.count = 0;
+        op_data.linktype = linkType;
+        op_data.basetype = baseType;
+
+        err = H5Literate(H5Object::getParent().getH5Id(), H5_INDEX_NAME, H5_ITER_INC, &idx, count, &op_data);
+
+        if (err < 0)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot get the number of groups %d."));
+        }
+
+        return op_data.u.count;
+    }
+
+    virtual std::string dump(std::map<haddr_t, std::string> & alreadyVisited, const un