Commit 668aa869 authored by Pierre Aubert's avatar Pierre Aubert
Browse files

The genreated class compiles

parent 19c5e4cd
......@@ -19,6 +19,11 @@ install(FILES FindPhoenixHDF5.cmake DESTINATION share/cmake)
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")
project(Phoenix)
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)
......@@ -2,5 +2,5 @@ project(Phoenix)
cmake_minimum_required(VERSION 2.8)
call_generator(test_base_config_lib baseConfig.ph5)
///Table of parameter
TableParameters{
///Position on the x axis
float x;
......
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)
......@@ -79,10 +79,10 @@ std::string ph5_backendTableHeaderOffset(const PTable & table){
* @return corresponding string
*/
std::string ph5_backendTableHeaderCompType(const PTable & table){
std::string body("\t\tstatic H5::CompType getCompTypeAll();\n");
std::string body("\t\tH5::CompType getCompTypeAll() const;\n");
const PVecAttribute & vecAttriute = table.getVecAttribute();
for(PVecAttribute::const_iterator it(vecAttriute.begin()); it != vecAttriute.end(); ++it){
body += "\t\tstatic H5::CompType getCompType" + firstToUpper(it->getName()) + "();\n";
body += "\t\tH5::CompType getCompType" + firstToUpper(it->getName()) + "() const;\n";
}
return body;
}
......@@ -95,7 +95,7 @@ std::string ph5_backendTableHeaderDataType(const PTable & table){
std::string body("");
const PVecAttribute & vecAttriute = table.getVecAttribute();
for(PVecAttribute::const_iterator it(vecAttriute.begin()); it != vecAttriute.end(); ++it){
body += "\t\tstatic H5::DataType getType" + firstToUpper(it->getName()) + "();\n";
body += "\t\tH5::DataType getType" + firstToUpper(it->getName()) + "() const;\n";
}
return body;
}
......@@ -191,6 +191,7 @@ std::string ph5_backendHeader(const PSource & source){
std::string baseMacro("__" + strToUpper(eraseExtension(source.getName())) + "_H__");
body += "#ifndef " + baseMacro + "\n";
body += "#define " + baseMacro + "\n\n";
body += "#include <iostream>\n";
body += "#include \"H5Cpp.h\"\n\n";
const PVecTable & vecTable = source.getVecTable();
......@@ -212,7 +213,7 @@ std::string ph5_backendTableSourceResize(const PTable & table){
body += "*/\n";
body += "void " + name + "::resize(size_t nbRow){\n";
body += "\tif(nbRow == p__nbRow){return;} //Nothing to do\n";
body += "\tclear()\n";
body += "\tclear();\n";
body += "\tallocate(nbRow);\n";
body += "}\n\n";
......@@ -269,22 +270,22 @@ std::string ph5_backendTableSourceWrite(const PTable & table){
body += "///Create and write the table " + name + " in given file\n";
body += "/**\t@param file : HDF5 file to be used\n";
body += "*/\n";
body += "void " + name + "::write(const H5::H5File & file) const{\n";
body += "void " + name + "::write(H5::H5File & file) const{\n";
body += "\thsize_t dim[1];\n";
body += "\tdim[0] = p__nbRow;\n";
body += "\tH5::DataSpace space(1, dim);\n";
body += "\tH5::DataSet dataset = file.createDataSet(\""+table.getDataSetName()+"\", " + name + "::getCompTypeAll(), space);\n";
body += "\tH5::DataSet dataset = file.createDataSet(\""+table.getDataSetName()+"\", getCompTypeAll(), space);\n";
body += "\twriteDataSet(dataset);\n";
body += "}\n\n";
body += "///Create and write the table " + name + " in given file\n";
body += "/**\t@param group : HDF5 group to be used\n";
body += "*/\n";
body += "void " + name + "::write(const H5::Group & group) const{\n";
body += "void " + name + "::write(H5::Group & group) const{\n";
body += "\thsize_t dim[1];\n";
body += "\tdim[0] = p__nbRow;\n";
body += "\tH5::DataSpace space(1, dim);\n";
body += "\tH5::DataSet dataset = group.createDataSet(\""+table.getDataSetName()+"\", " + name + "::getCompTypeAll(), space);\n";
body += "\tH5::DataSet dataset = group.createDataSet(\""+table.getDataSetName()+"\", getCompTypeAll(), space);\n";
body += "\twriteDataSet(dataset);\n";
body += "}\n\n";
return body;
......@@ -451,7 +452,7 @@ std::string ph5_backendTableSourceOffset(const PTable & table){
std::string ph5_backendTableSourceCompType(const PTable & table){
std::string body(""), name(table.getName());
const PVecAttribute & vecAttriute = table.getVecAttribute();
body += "H5::CompType "+name+"::getCompTypeAll(){\n";
body += "H5::CompType "+name+"::getCompTypeAll() const{\n";
body += "\tsize_t sizeAll(";
bool addPlus(false);
for(PVecAttribute::const_iterator it(vecAttriute.begin()); it != vecAttriute.end(); ++it){
......@@ -472,9 +473,9 @@ std::string ph5_backendTableSourceCompType(const PTable & table){
body += "///Get DataType of attribute "+it->getName() +" (column " + it->getColName() + ")\n";
body += "/**\t@return DataType of the attribute "+it->getName() +"\n";
body += "*/\n";
body += "H5::CompType "+name+"::getCompType" + firstToUpper(it->getName()) + "(){\n";
body += "H5::CompType "+name+"::getCompType" + firstToUpper(it->getName()) + "() const{\n";
body += "\tH5::CompType typeCol("+ph5_getSizeOfCol(*it)+");\n";
body += "\tdatasetTypeX.insertMember(\""+it->getColName()+"\", 0, "+name+"::getType" + firstToUpper(it->getName()) + "());\n";
body += "\ttypeCol.insertMember(\""+it->getColName()+"\", 0, getType" + firstToUpper(it->getName()) + "());\n";
body += "\treturn typeCol;\n";
body += "}\n\n";
}
......@@ -529,7 +530,7 @@ std::string ph5_backendTableSourceDataType(const PTable & table){
body += "///Get DataType of attribute "+it->getName() +" (column " + it->getColName() + ")\n";
body += "/**\t@return DataType of the attribute "+it->getName() +"\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 += "}\n\n";
}
......@@ -551,7 +552,7 @@ std::string ph5_backendTableSourceReadDataSet(const PTable & table){
body += "\tresize(nbEntries);\n";
const PVecAttribute & vecAttriute = table.getVecAttribute();
for(PVecAttribute::const_iterator it(vecAttriute.begin()); it != vecAttriute.end(); ++it){
body += "\tdataset.read(p_"+it->getName()+", "+name+"::getCompType" + firstToUpper(it->getName()) + "());\n";
body += "\tdataset.read(p_"+it->getName()+", getCompType" + firstToUpper(it->getName()) + "());\n";
}
body += "}\n\n";
return body;
......@@ -569,7 +570,7 @@ std::string ph5_backendTableSourceWriteDataSet(const PTable & table){
body += "void "+name+"::writeDataSet(H5::DataSet & dataset) const{\n";
const PVecAttribute & vecAttriute = table.getVecAttribute();
for(PVecAttribute::const_iterator it(vecAttriute.begin()); it != vecAttriute.end(); ++it){
body += "\tdataset.write(p_"+it->getName()+", "+name+"::getCompType" + firstToUpper(it->getName()) + "());\n";
body += "\tdataset.write(p_"+it->getName()+", getCompType" + firstToUpper(it->getName()) + "());\n";
}
body += "}\n\n";
return body;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment