Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CTA-LAPP
PHOENIX_LIBS
PhoenixHDF5
Commits
668aa869
Commit
668aa869
authored
Nov 25, 2020
by
Pierre Aubert
Browse files
The genreated class compiles
parent
19c5e4cd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
16 deletions
+65
-16
CMakeLists.txt
CMakeLists.txt
+5
-0
TESTS/CMakeLists.txt
TESTS/CMakeLists.txt
+8
-0
TESTS/TEST_BASE_CONFIG/CMakeLists.txt
TESTS/TEST_BASE_CONFIG/CMakeLists.txt
+1
-1
TESTS/TEST_BASE_CONFIG/baseConfig.ph5
TESTS/TEST_BASE_CONFIG/baseConfig.ph5
+1
-1
TESTS/callGenerator.cmake
TESTS/callGenerator.cmake
+35
-0
src/BackEnd/backend.cpp
src/BackEnd/backend.cpp
+15
-14
No files found.
CMakeLists.txt
View file @
668aa869
...
@@ -19,6 +19,11 @@ install(FILES FindPhoenixHDF5.cmake DESTINATION share/cmake)
...
@@ -19,6 +19,11 @@ install(FILES FindPhoenixHDF5.cmake DESTINATION share/cmake)
add_subdirectory
(
src
)
add_subdirectory
(
src
)
if
(
SELF_TESTS_MODE
)
include
(
CTest
)
add_subdirectory
(
TESTS
)
endif
(
SELF_TESTS_MODE
)
set
(
PHOENIX_INCLUDE_DIRS
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src;
${
PHOENIX_INCLUDE_DIRS
}
"
CACHE INTERNAL
"list of Phoenix include dirs"
)
set
(
PHOENIX_INCLUDE_DIRS
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src;
${
PHOENIX_INCLUDE_DIRS
}
"
CACHE INTERNAL
"list of Phoenix include dirs"
)
TESTS/CMakeLists.txt
View file @
668aa869
project
(
Phoenix
)
project
(
Phoenix
)
cmake_minimum_required
(
VERSION 2.8
)
cmake_minimum_required
(
VERSION 2.8
)
find_package
(
HDF5 COMPONENTS C CXX REQUIRED
)
include_directories
(
${
HDF5_INCLUDE_DIRS
}
)
message
(
STATUS
"HDF5_CXX_LIBRARIES =
${
HDF5_CXX_LIBRARIES
}
"
)
include
(
callGenerator.cmake
)
add_subdirectory
(
TEST_BASE_CONFIG
)
add_subdirectory
(
TEST_BASE_CONFIG
)
TESTS/TEST_BASE_CONFIG/CMakeLists.txt
View file @
668aa869
...
@@ -2,5 +2,5 @@ project(Phoenix)
...
@@ -2,5 +2,5 @@ project(Phoenix)
cmake_minimum_required
(
VERSION 2.8
)
cmake_minimum_required
(
VERSION 2.8
)
call_generator
(
test_base_config_lib baseConfig.ph5
)
TESTS/TEST_BASE_CONFIG/baseConfig.ph5
View file @
668aa869
///Table of parameter
TableParameters{
TableParameters{
///Position on the x axis
///Position on the x axis
float x;
float x;
...
...
TESTS/callGenerator.cmake
0 → 100644
View file @
668aa869
set
(
PHOENIX_HDF5_PROGRAM
"
${
CMAKE_BINARY_DIR
}
/src/phoenix_hdf5"
)
# Function which call the generator on configuration file and compile a library
# targetName : name of the target to be created
# ARGN : list of configuration files to be passed to the phoenix_hdf5 generator
function
(
call_generator targetName
)
set
(
listOutputFile
)
set
(
listInputFile
)
foreach
(
configFile
${
ARGN
}
)
get_filename_component
(
absolutePath
${
configFile
}
ABSOLUTE
)
list
(
APPEND listInputFile
${
absolutePath
}
)
message
(
STATUS
"Absolute path '
${
absolutePath
}
'"
)
get_filename_component
(
baseNameConfig
${
configFile
}
NAME_WE
)
set
(
outputFile
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
baseNameConfig
}
.cpp"
)
list
(
APPEND listOutputFile
${
outputFile
}
)
endforeach
(
configFile
)
add_custom_command
(
OUTPUT
${
listOutputFile
}
COMMAND
${
PHOENIX_HDF5_PROGRAM
}
-i
"
${
listInputFile
}
"
WORKING_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
COMMENT
"Create sources of library
${
targetName
}
"
DEPENDS
${
PHOENIX_HDF5_PROGRAM
}
${
listInputFile
}
)
set
(
targetCreateSource
"
${
targetName
}
_createSource"
)
add_custom_target
(
${
targetCreateSource
}
ALL DEPENDS
${
listOutputFile
}
)
add_library
(
${
targetName
}
SHARED
${
listOutputFile
}
)
target_link_libraries
(
${
targetName
}
${
HDF5_CXX_LIBRARIES
}
)
add_dependencies
(
${
targetName
}
${
targetCreateSource
}
)
endfunction
(
call_generator
)
src/BackEnd/backend.cpp
View file @
668aa869
...
@@ -79,10 +79,10 @@ std::string ph5_backendTableHeaderOffset(const PTable & table){
...
@@ -79,10 +79,10 @@ std::string ph5_backendTableHeaderOffset(const PTable & table){
* @return corresponding string
* @return corresponding string
*/
*/
std
::
string
ph5_backendTableHeaderCompType
(
const
PTable
&
table
){
std
::
string
ph5_backendTableHeaderCompType
(
const
PTable
&
table
){
std
::
string
body
(
"
\t\t
static
H5::CompType getCompTypeAll();
\n
"
);
std
::
string
body
(
"
\t\t
H5::CompType getCompTypeAll()
const
;
\n
"
);
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t\t
static
H5::CompType getCompType"
+
firstToUpper
(
it
->
getName
())
+
"();
\n
"
;
body
+=
"
\t\t
H5::CompType getCompType"
+
firstToUpper
(
it
->
getName
())
+
"()
const
;
\n
"
;
}
}
return
body
;
return
body
;
}
}
...
@@ -95,7 +95,7 @@ std::string ph5_backendTableHeaderDataType(const PTable & table){
...
@@ -95,7 +95,7 @@ std::string ph5_backendTableHeaderDataType(const PTable & table){
std
::
string
body
(
""
);
std
::
string
body
(
""
);
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t\t
static
H5::DataType getType"
+
firstToUpper
(
it
->
getName
())
+
"();
\n
"
;
body
+=
"
\t\t
H5::DataType getType"
+
firstToUpper
(
it
->
getName
())
+
"()
const
;
\n
"
;
}
}
return
body
;
return
body
;
}
}
...
@@ -191,6 +191,7 @@ std::string ph5_backendHeader(const PSource & source){
...
@@ -191,6 +191,7 @@ std::string ph5_backendHeader(const PSource & source){
std
::
string
baseMacro
(
"__"
+
strToUpper
(
eraseExtension
(
source
.
getName
()))
+
"_H__"
);
std
::
string
baseMacro
(
"__"
+
strToUpper
(
eraseExtension
(
source
.
getName
()))
+
"_H__"
);
body
+=
"#ifndef "
+
baseMacro
+
"
\n
"
;
body
+=
"#ifndef "
+
baseMacro
+
"
\n
"
;
body
+=
"#define "
+
baseMacro
+
"
\n\n
"
;
body
+=
"#define "
+
baseMacro
+
"
\n\n
"
;
body
+=
"#include <iostream>
\n
"
;
body
+=
"#include
\"
H5Cpp.h
\"\n\n
"
;
body
+=
"#include
\"
H5Cpp.h
\"\n\n
"
;
const
PVecTable
&
vecTable
=
source
.
getVecTable
();
const
PVecTable
&
vecTable
=
source
.
getVecTable
();
...
@@ -212,7 +213,7 @@ std::string ph5_backendTableSourceResize(const PTable & table){
...
@@ -212,7 +213,7 @@ std::string ph5_backendTableSourceResize(const PTable & table){
body
+=
"*/
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"void "
+
name
+
"::resize(size_t nbRow){
\n
"
;
body
+=
"void "
+
name
+
"::resize(size_t nbRow){
\n
"
;
body
+=
"
\t
if(nbRow == p__nbRow){return;} //Nothing to do
\n
"
;
body
+=
"
\t
if(nbRow == p__nbRow){return;} //Nothing to do
\n
"
;
body
+=
"
\t
clear()
\n
"
;
body
+=
"
\t
clear()
;
\n
"
;
body
+=
"
\t
allocate(nbRow);
\n
"
;
body
+=
"
\t
allocate(nbRow);
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
"}
\n\n
"
;
...
@@ -269,22 +270,22 @@ std::string ph5_backendTableSourceWrite(const PTable & table){
...
@@ -269,22 +270,22 @@ std::string ph5_backendTableSourceWrite(const PTable & table){
body
+=
"///Create and write the table "
+
name
+
" in given file
\n
"
;
body
+=
"///Create and write the table "
+
name
+
" in given file
\n
"
;
body
+=
"/**
\t
@param file : HDF5 file to be used
\n
"
;
body
+=
"/**
\t
@param file : HDF5 file to be used
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"void "
+
name
+
"::write(
const
H5::H5File & file) const{
\n
"
;
body
+=
"void "
+
name
+
"::write(H5::H5File & file) const{
\n
"
;
body
+=
"
\t
hsize_t dim[1];
\n
"
;
body
+=
"
\t
hsize_t dim[1];
\n
"
;
body
+=
"
\t
dim[0] = p__nbRow;
\n
"
;
body
+=
"
\t
dim[0] = p__nbRow;
\n
"
;
body
+=
"
\t
H5::DataSpace space(1, dim);
\n
"
;
body
+=
"
\t
H5::DataSpace space(1, dim);
\n
"
;
body
+=
"
\t
H5::DataSet dataset = file.createDataSet(
\"
"
+
table
.
getDataSetName
()
+
"
\"
,
"
+
name
+
"::
getCompTypeAll(), space);
\n
"
;
body
+=
"
\t
H5::DataSet dataset = file.createDataSet(
\"
"
+
table
.
getDataSetName
()
+
"
\"
, getCompTypeAll(), space);
\n
"
;
body
+=
"
\t
writeDataSet(dataset);
\n
"
;
body
+=
"
\t
writeDataSet(dataset);
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
"}
\n\n
"
;
body
+=
"///Create and write the table "
+
name
+
" in given file
\n
"
;
body
+=
"///Create and write the table "
+
name
+
" in given file
\n
"
;
body
+=
"/**
\t
@param group : HDF5 group to be used
\n
"
;
body
+=
"/**
\t
@param group : HDF5 group to be used
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"void "
+
name
+
"::write(
const
H5::Group & group) const{
\n
"
;
body
+=
"void "
+
name
+
"::write(H5::Group & group) const{
\n
"
;
body
+=
"
\t
hsize_t dim[1];
\n
"
;
body
+=
"
\t
hsize_t dim[1];
\n
"
;
body
+=
"
\t
dim[0] = p__nbRow;
\n
"
;
body
+=
"
\t
dim[0] = p__nbRow;
\n
"
;
body
+=
"
\t
H5::DataSpace space(1, dim);
\n
"
;
body
+=
"
\t
H5::DataSpace space(1, dim);
\n
"
;
body
+=
"
\t
H5::DataSet dataset = group.createDataSet(
\"
"
+
table
.
getDataSetName
()
+
"
\"
,
"
+
name
+
"::
getCompTypeAll(), space);
\n
"
;
body
+=
"
\t
H5::DataSet dataset = group.createDataSet(
\"
"
+
table
.
getDataSetName
()
+
"
\"
, getCompTypeAll(), space);
\n
"
;
body
+=
"
\t
writeDataSet(dataset);
\n
"
;
body
+=
"
\t
writeDataSet(dataset);
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
"}
\n\n
"
;
return
body
;
return
body
;
...
@@ -451,7 +452,7 @@ std::string ph5_backendTableSourceOffset(const PTable & table){
...
@@ -451,7 +452,7 @@ std::string ph5_backendTableSourceOffset(const PTable & table){
std
::
string
ph5_backendTableSourceCompType
(
const
PTable
&
table
){
std
::
string
ph5_backendTableSourceCompType
(
const
PTable
&
table
){
std
::
string
body
(
""
),
name
(
table
.
getName
());
std
::
string
body
(
""
),
name
(
table
.
getName
());
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
body
+=
"H5::CompType "
+
name
+
"::getCompTypeAll(){
\n
"
;
body
+=
"H5::CompType "
+
name
+
"::getCompTypeAll()
const
{
\n
"
;
body
+=
"
\t
size_t sizeAll("
;
body
+=
"
\t
size_t sizeAll("
;
bool
addPlus
(
false
);
bool
addPlus
(
false
);
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
...
@@ -472,9 +473,9 @@ std::string ph5_backendTableSourceCompType(const PTable & table){
...
@@ -472,9 +473,9 @@ std::string ph5_backendTableSourceCompType(const PTable & table){
body
+=
"///Get DataType of attribute "
+
it
->
getName
()
+
" (column "
+
it
->
getColName
()
+
")
\n
"
;
body
+=
"///Get DataType of attribute "
+
it
->
getName
()
+
" (column "
+
it
->
getColName
()
+
")
\n
"
;
body
+=
"/**
\t
@return DataType of the attribute "
+
it
->
getName
()
+
"
\n
"
;
body
+=
"/**
\t
@return DataType of the attribute "
+
it
->
getName
()
+
"
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"H5::CompType "
+
name
+
"::getCompType"
+
firstToUpper
(
it
->
getName
())
+
"(){
\n
"
;
body
+=
"H5::CompType "
+
name
+
"::getCompType"
+
firstToUpper
(
it
->
getName
())
+
"()
const
{
\n
"
;
body
+=
"
\t
H5::CompType typeCol("
+
ph5_getSizeOfCol
(
*
it
)
+
");
\n
"
;
body
+=
"
\t
H5::CompType typeCol("
+
ph5_getSizeOfCol
(
*
it
)
+
");
\n
"
;
body
+=
"
\t
datasetTypeX
.insertMember(
\"
"
+
it
->
getColName
()
+
"
\"
, 0,
"
+
name
+
"::
getType"
+
firstToUpper
(
it
->
getName
())
+
"());
\n
"
;
body
+=
"
\t
typeCol
.insertMember(
\"
"
+
it
->
getColName
()
+
"
\"
, 0, getType"
+
firstToUpper
(
it
->
getName
())
+
"());
\n
"
;
body
+=
"
\t
return typeCol;
\n
"
;
body
+=
"
\t
return typeCol;
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
"}
\n\n
"
;
}
}
...
@@ -529,7 +530,7 @@ std::string ph5_backendTableSourceDataType(const PTable & table){
...
@@ -529,7 +530,7 @@ std::string ph5_backendTableSourceDataType(const PTable & table){
body
+=
"///Get DataType of attribute "
+
it
->
getName
()
+
" (column "
+
it
->
getColName
()
+
")
\n
"
;
body
+=
"///Get DataType of attribute "
+
it
->
getName
()
+
" (column "
+
it
->
getColName
()
+
")
\n
"
;
body
+=
"/**
\t
@return DataType of the attribute "
+
it
->
getName
()
+
"
\n
"
;
body
+=
"/**
\t
@return DataType of the attribute "
+
it
->
getName
()
+
"
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"H5::DataType "
+
name
+
"::getType"
+
firstToUpper
(
it
->
getName
())
+
"(){
\n
"
;
body
+=
"H5::DataType "
+
name
+
"::getType"
+
firstToUpper
(
it
->
getName
())
+
"()
const
{
\n
"
;
body
+=
ph5_getTypeHDF5
(
*
it
);
body
+=
ph5_getTypeHDF5
(
*
it
);
body
+=
"}
\n\n
"
;
body
+=
"}
\n\n
"
;
}
}
...
@@ -551,7 +552,7 @@ std::string ph5_backendTableSourceReadDataSet(const PTable & table){
...
@@ -551,7 +552,7 @@ std::string ph5_backendTableSourceReadDataSet(const PTable & table){
body
+=
"
\t
resize(nbEntries);
\n
"
;
body
+=
"
\t
resize(nbEntries);
\n
"
;
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t
dataset.read(p_"
+
it
->
getName
()
+
",
"
+
name
+
"::
getCompType"
+
firstToUpper
(
it
->
getName
())
+
"());
\n
"
;
body
+=
"
\t
dataset.read(p_"
+
it
->
getName
()
+
", getCompType"
+
firstToUpper
(
it
->
getName
())
+
"());
\n
"
;
}
}
body
+=
"}
\n\n
"
;
body
+=
"}
\n\n
"
;
return
body
;
return
body
;
...
@@ -569,7 +570,7 @@ std::string ph5_backendTableSourceWriteDataSet(const PTable & table){
...
@@ -569,7 +570,7 @@ std::string ph5_backendTableSourceWriteDataSet(const PTable & table){
body
+=
"void "
+
name
+
"::writeDataSet(H5::DataSet & dataset) const{
\n
"
;
body
+=
"void "
+
name
+
"::writeDataSet(H5::DataSet & dataset) const{
\n
"
;
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t
dataset.write(p_"
+
it
->
getName
()
+
",
"
+
name
+
"::
getCompType"
+
firstToUpper
(
it
->
getName
())
+
"());
\n
"
;
body
+=
"
\t
dataset.write(p_"
+
it
->
getName
()
+
", getCompType"
+
firstToUpper
(
it
->
getName
())
+
"());
\n
"
;
}
}
body
+=
"}
\n\n
"
;
body
+=
"}
\n\n
"
;
return
body
;
return
body
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment