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
bcc079e6
Commit
bcc079e6
authored
Nov 24, 2020
by
Pierre Aubert
Browse files
Add base of backend
parent
c2bd6350
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
197 additions
and
4 deletions
+197
-4
src/BackEnd/backend.cpp
src/BackEnd/backend.cpp
+165
-1
src/BackEnd/backend.h
src/BackEnd/backend.h
+3
-3
src/Representation/PRepr.cpp
src/Representation/PRepr.cpp
+22
-0
src/Representation/PRepr.h
src/Representation/PRepr.h
+5
-0
src/Representation/PRepr.pdata
src/Representation/PRepr.pdata
+2
-0
No files found.
src/BackEnd/backend.cpp
View file @
bcc079e6
...
...
@@ -4,10 +4,174 @@
Licence : CeCILL-C
****************************************/
#include "string_utils.h"
#include "backend.h"
///Get the licence in string
/** @return licence in string
*/
std
::
string
ph5_licenceSaveStr
(){
std
::
string
body
(
""
);
body
+=
"/***************************************
\n
"
;
body
+=
"
\t
Auteur : Pierre Aubert
\n
"
;
body
+=
"
\t
Mail : aubertp7@gmail.com
\n
"
;
body
+=
"
\t
Licence : CeCILL-C
\n
"
;
body
+=
"****************************************/
\n\n\n
"
;
body
+=
"//Warning : this file has been generated automatically by the phoenix_hdf5 program
\n
"
;
body
+=
"//Do NOT modify it
\n\n\n
"
;
return
body
;
}
///Save the header of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableHeaderCompType
(
const
PTable
&
table
){
std
::
string
body
(
"
\t\t
static H5::CompType getTypeAll();
\n
"
);
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
body
+=
"
\t\t
static H5::CompType getType"
+
firstToUpper
(
it
->
getName
())
+
"();
\n
"
;
}
return
body
;
}
///Save the header of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableHeaderAttribute
(
const
PTable
&
table
){
std
::
string
body
(
""
);
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
if
(
it
->
getDocString
()
!=
""
){
body
+=
"
\t\t
///"
+
it
->
getDocString
()
+
"
\n
"
;
}
body
+=
"
\t\t
"
+
it
->
getType
()
+
" * p_"
+
it
->
getName
()
+
";
\n
"
;
}
return
body
;
}
///Save the header of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableHeader
(
const
PTable
&
table
){
std
::
string
body
(
""
);
if
(
table
.
getDocString
()
!=
""
){
body
+=
"///"
+
table
.
getDocString
()
+
"
\n
"
;
}
std
::
string
name
(
table
.
getName
());
body
+=
"class "
+
name
+
"{
\n
"
;
body
+=
"
\t
public:
\n
"
;
body
+=
"
\t\t
"
+
name
+
"();
\n
"
;
body
+=
"
\t\t
virtual ~"
+
name
+
"();
\n
"
;
body
+=
"
\t\t
void resize(size_t nbRow);
\n
"
;
body
+=
"
\t\t
void clear();
\n\n
"
;
body
+=
"
\t\t
void read(const H5::H5File & file);
\n
"
;
body
+=
"
\t\t
void read(const H5::Group & group);
\n\n
"
;
body
+=
"
\t\t
void write(H5::H5File & file) const;
\n
"
;
body
+=
"
\t\t
void write(H5::Group & group) const;
\n\n
"
;
body
+=
ph5_backendTableHeaderCompType
(
table
);
body
+=
"
\t
private:
\n
"
;
body
+=
"
\t\t
///Number of rows in the table "
+
name
+
"
\n
"
;
body
+=
"
\t\t
size_t p_nbRow;
\n
"
;
body
+=
ph5_backendTableHeaderAttribute
(
table
);
body
+=
"};
\n\n
"
;
return
body
;
}
///Save the header of the given PSource
/** @param source : PSource to be used
* @return corresponding string
*/
std
::
string
ph5_backendHeader
(
const
PSource
&
source
){
std
::
string
body
(
ph5_licenceSaveStr
());
std
::
string
baseMacro
(
"__"
+
strToUpper
(
source
.
getName
())
+
"_H__"
);
body
+=
"#ifndef "
+
baseMacro
+
"
\n
"
;
body
+=
"#define "
+
baseMacro
+
"
\n\n
"
;
body
+=
"#include
\"
H5Cpp.h
\"\n\n
"
;
const
PVecTable
&
vecTable
=
source
.
getVecTable
();
for
(
PVecTable
::
const_iterator
it
(
vecTable
.
begin
());
it
!=
vecTable
.
end
();
++
it
){
body
+=
ph5_backendTableHeader
(
*
it
);
}
body
+=
"#endif
\n\n
"
;
return
body
;
}
///Save the source of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableSource
(
const
PTable
&
table
){
std
::
string
body
(
""
),
name
(
table
.
getName
());
body
+=
"///Constructor of the class "
+
name
+
"
\n
"
;
body
+=
name
+
"::"
+
name
+
"(){
\n
"
;
body
+=
"
\t
p_nbRow = 0lu;
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
"///Destructor of the class "
+
name
+
"
\n
"
;
body
+=
name
+
"::~"
+
name
+
"(){
\n
"
;
body
+=
"
\t\n
"
;
body
+=
"}
\n\n
"
;
return
body
;
}
///Save the source of the given PSource
/** @param source : PSource to be used
* @return corresponding string
*/
std
::
string
ph5_backendSource
(
const
PSource
&
source
){
std
::
string
body
(
ph5_licenceSaveStr
());
body
+=
"#include
\"
"
+
source
.
getName
()
+
".h
\"\n\n
"
;
const
PVecTable
&
vecTable
=
source
.
getVecTable
();
for
(
PVecTable
::
const_iterator
it
(
vecTable
.
begin
());
it
!=
vecTable
.
end
();
++
it
){
body
+=
ph5_backendTableSource
(
*
it
);
}
return
body
;
}
///Save a vector of PSource in the output directory
/** @param source : source to be saved
* @param outputDir : output directory where to save PSource
* @return true on success, false otherwise
*/
bool
ph5_backend
(
const
PSource
&
source
,
const
std
::
string
&
outputDir
){
std
::
string
headerSrc
(
ph5_backendHeader
(
source
));
std
::
string
sourceSrc
(
ph5_backendSource
(
source
));
std
::
string
outputHeaderFile
(
outputDir
+
"/"
+
source
.
getName
()
+
".h"
);
std
::
string
outputSourceFile
(
outputDir
+
"/"
+
source
.
getName
()
+
".cpp"
);
if
(
saveFileContent
(
outputHeaderFile
,
headerSrc
)){
std
::
cerr
<<
"ph5_backend : cannot save header file '"
<<
outputHeaderFile
<<
"'"
<<
std
::
endl
;
return
false
;
}
if
(
saveFileContent
(
outputSourceFile
,
sourceSrc
)){
std
::
cerr
<<
"ph5_backend : cannot save source file '"
<<
outputSourceFile
<<
"'"
<<
std
::
endl
;
return
false
;
}
return
true
;
}
///Save a vector of PSource in the output directory
/** @param vecSource : vector of source
* @param outputDir : output directory where to save PSource
* @return true on success, false otherwise
*/
bool
ph5_backend
(
const
PVecSource
&
vecSource
,
const
std
::
string
&
outputDir
){
bool
b
(
true
);
for
(
PVecSource
::
const_iterator
it
(
vecSource
.
begin
());
it
!=
vecSource
.
end
();
++
it
){
b
&=
ph5_backend
(
*
it
,
outputDir
);
}
return
b
;
}
src/BackEnd/backend.h
View file @
bcc079e6
...
...
@@ -7,9 +7,9 @@
#ifndef __BACKEND_H__
#define __BACKEND_H__
#include "Representation/representation.h"
bool
ph5_backend
(
const
PSource
&
source
,
const
std
::
string
&
outputDir
);
bool
ph5_backend
(
const
PVecSource
&
vecSource
,
const
std
::
string
&
outputDir
);
#endif
src/Representation/PRepr.cpp
View file @
bcc079e6
...
...
@@ -294,6 +294,13 @@ void PTable::setVarNbEntry(const std::string & varNbEntry){
p_varNbEntry
=
varNbEntry
;
}
///Sets the docString of the PTable
/** @param docString : docString of the PTable
*/
void
PTable
::
setDocString
(
const
std
::
string
&
docString
){
p_docString
=
docString
;
}
///Sets the vecAttribute of the PTable
/** @param vecAttribute : vecAttribute of the PTable
*/
...
...
@@ -343,6 +350,20 @@ std::string & PTable::getVarNbEntry(){
return
p_varNbEntry
;
}
///Gets the docString of the PTable
/** @return docString of the PTable
*/
const
std
::
string
&
PTable
::
getDocString
()
const
{
return
p_docString
;
}
///Gets the docString of the PTable
/** @return docString of the PTable
*/
std
::
string
&
PTable
::
getDocString
(){
return
p_docString
;
}
///Gets the vecAttribute of the PTable
/** @return vecAttribute of the PTable
*/
...
...
@@ -364,6 +385,7 @@ void PTable::copyPTable(const PTable & other){
p_name
=
other
.
p_name
;
p_dataSetName
=
other
.
p_dataSetName
;
p_varNbEntry
=
other
.
p_varNbEntry
;
p_docString
=
other
.
p_docString
;
p_vecAttribute
=
other
.
p_vecAttribute
;
}
...
...
src/Representation/PRepr.h
View file @
bcc079e6
...
...
@@ -84,6 +84,7 @@ class PTable{
void
setName
(
const
std
::
string
&
name
);
void
setDataSetName
(
const
std
::
string
&
dataSetName
);
void
setVarNbEntry
(
const
std
::
string
&
varNbEntry
);
void
setDocString
(
const
std
::
string
&
docString
);
void
setVecAttribute
(
const
std
::
vector
<
PAttribute
>
&
vecAttribute
);
const
std
::
string
&
getName
()
const
;
std
::
string
&
getName
();
...
...
@@ -91,6 +92,8 @@ class PTable{
std
::
string
&
getDataSetName
();
const
std
::
string
&
getVarNbEntry
()
const
;
std
::
string
&
getVarNbEntry
();
const
std
::
string
&
getDocString
()
const
;
std
::
string
&
getDocString
();
const
std
::
vector
<
PAttribute
>
&
getVecAttribute
()
const
;
std
::
vector
<
PAttribute
>
&
getVecAttribute
();
protected:
...
...
@@ -102,6 +105,8 @@ class PTable{
std
::
string
p_dataSetName
;
///Name of the variable which describes the number of entries (or row) of the current PTable (or DataSet)
std
::
string
p_varNbEntry
;
///Documentation string of the current PTable
std
::
string
p_docString
;
///Vector of all the attributes of the PTable
std
::
vector
<
PAttribute
>
p_vecAttribute
;
};
...
...
src/Representation/PRepr.pdata
View file @
bcc079e6
...
...
@@ -34,6 +34,8 @@ PTable{
std::string dataSetName;
///Name of the variable which describes the number of entries (or row) of the current PTable (or DataSet)
std::string varNbEntry;
///Documentation string of the current PTable
std::string docString;
///Vector of all the attributes of the PTable
std::vector<PAttribute> vecAttribute;
}
...
...
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