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
bf087d72
Commit
bf087d72
authored
Nov 24, 2020
by
Pierre Aubert
Browse files
Add getters and setters
parent
d949871e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
3 deletions
+140
-3
src/BackEnd/backend.cpp
src/BackEnd/backend.cpp
+119
-0
src/Representation/representation.cpp
src/Representation/representation.cpp
+19
-2
src/Representation/representation.h
src/Representation/representation.h
+2
-1
No files found.
src/BackEnd/backend.cpp
View file @
bf087d72
...
@@ -23,6 +23,45 @@ std::string ph5_licenceSaveStr(){
...
@@ -23,6 +23,45 @@ std::string ph5_licenceSaveStr(){
return
body
;
return
body
;
}
}
///Save the header of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableHeaderSetter
(
const
PTable
&
table
){
std
::
string
body
(
""
);
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
std
::
string
type
(
it
->
getType
());
if
(
ph5_attributeIsTensor
(
*
it
)){
body
+=
"
\t\t
void set"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i, const "
+
type
+
" * tabVal);
\n
"
;
}
else
{
body
+=
"
\t\t
void set"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i, "
+
type
+
" val);
\n
"
;
}
}
return
body
;
}
///Save the header of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableHeaderGetter
(
const
PTable
&
table
){
std
::
string
body
(
""
);
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
std
::
string
type
(
it
->
getType
());
if
(
ph5_attributeIsTensor
(
*
it
)){
body
+=
"
\t\t
const "
+
type
+
" * get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i) const;
\n
"
;
body
+=
"
\t\t
"
+
type
+
" * get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i);
\n
"
;
}
else
{
body
+=
"
\t\t
"
+
type
+
" get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i) const;
\n
"
;
body
+=
"
\t\t
"
+
type
+
" & get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i);
\n
"
;
}
}
return
body
;
}
///Save the header of the given PTable
///Save the header of the given PTable
/** @param table : PTable to be used
/** @param table : PTable to be used
* @return corresponding string
* @return corresponding string
...
@@ -101,6 +140,9 @@ std::string ph5_backendTableHeader(const PTable & table){
...
@@ -101,6 +140,9 @@ std::string ph5_backendTableHeader(const PTable & table){
body
+=
"
\t\t
void write(H5::H5File & file) const;
\n
"
;
body
+=
"
\t\t
void write(H5::H5File & file) const;
\n
"
;
body
+=
"
\t\t
void write(H5::Group & group) const;
\n\n
"
;
body
+=
"
\t\t
void write(H5::Group & group) const;
\n\n
"
;
body
+=
ph5_backendTableHeaderSetter
(
table
);
body
+=
ph5_backendTableHeaderGetter
(
table
);
body
+=
"
\n
"
;
body
+=
ph5_backendTableHeaderOffset
(
table
);
body
+=
ph5_backendTableHeaderOffset
(
table
);
body
+=
ph5_backendTableHeaderCompType
(
table
);
body
+=
ph5_backendTableHeaderCompType
(
table
);
body
+=
ph5_backendTableHeaderDataType
(
table
);
body
+=
ph5_backendTableHeaderDataType
(
table
);
...
@@ -225,6 +267,79 @@ std::string ph5_backendTableSourceWrite(const PTable & table){
...
@@ -225,6 +267,79 @@ std::string ph5_backendTableSourceWrite(const PTable & table){
return
body
;
return
body
;
}
}
///Save the header of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableSourceSetter
(
const
PTable
&
table
){
std
::
string
body
(
""
),
name
(
table
.
getName
());
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
std
::
string
type
(
it
->
getType
());
body
+=
"///Set the attribute "
+
it
->
getName
()
+
" (column "
+
it
->
getColName
()
+
")
\n
"
;
if
(
ph5_attributeIsTensor
(
*
it
)){
body
+=
"/**
\t
@param i : index of the row to be used
\n
"
;
body
+=
" *
\t
@param tabVal : table of value to be copied
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"void "
+
name
+
"::set"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i, const "
+
type
+
" * tabVal){
\n
"
;
body
+=
"
\t
size_t sizeRow("
+
ph5_getFullAttributeElement
(
*
it
)
+
");
\n
"
;
body
+=
"
\t
memcpy(p_"
+
it
->
getName
()
+
" + i*sizeRow, tabVal, sizeRow);
\n
"
;
body
+=
"}
\n\n
"
;
}
else
{
body
+=
"/**
\t
@param i : index of the row to be used
\n
"
;
body
+=
" *
\t
@param val : value to be copied
\n
"
;
body
+=
"*/
\n
"
;
body
+=
"void "
+
name
+
"::set"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i, "
+
type
+
" val){
\n
"
;
body
+=
"
\t
p_"
+
it
->
getName
()
+
"[i] = val;
\n
"
;
body
+=
"}
\n\n
"
;
}
}
return
body
;
}
///Save the header of the given PTable
/** @param table : PTable to be used
* @return corresponding string
*/
std
::
string
ph5_backendTableSourceGetter
(
const
PTable
&
table
){
std
::
string
body
(
""
),
name
(
table
.
getName
());
const
PVecAttribute
&
vecAttriute
=
table
.
getVecAttribute
();
for
(
PVecAttribute
::
const_iterator
it
(
vecAttriute
.
begin
());
it
!=
vecAttriute
.
end
();
++
it
){
std
::
string
type
(
it
->
getType
());
if
(
ph5_attributeIsTensor
(
*
it
)){
std
::
string
docString
(
""
);
docString
+=
"///Get the tensor i of the attribute "
+
it
->
getName
()
+
" (column "
+
it
->
getColName
()
+
")
\n
"
;
docString
+=
"/**
\t
@param i : index of the row to be used
\n
"
;
docString
+=
" *
\t
@return pointer to the corresponding tensor
\n
"
;
docString
+=
"*/
\n
"
;
body
+=
docString
;
std
::
string
sizeElement
(
ph5_getFullAttributeElement
(
*
it
));
body
+=
"const "
+
type
+
" * "
+
name
+
"::get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i) const{
\n
"
;
body
+=
"return p_"
+
it
->
getName
()
+
" + i*"
+
sizeElement
+
";
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
docString
;
body
+=
type
+
" * "
+
name
+
"::get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i){
\n
"
;
body
+=
"return p_"
+
it
->
getName
()
+
" + i**"
+
sizeElement
+
";
\n
"
;
body
+=
"}
\n\n
"
;
}
else
{
std
::
string
docString
(
""
);
docString
+=
"///Get the value i of the attribute "
+
it
->
getName
()
+
" (column "
+
it
->
getColName
()
+
")
\n
"
;
docString
+=
"/**
\t
@param i : index of the row to be used
\n
"
;
docString
+=
" *
\t
@return corresponding value
\n
"
;
docString
+=
"*/
\n
"
;
body
+=
docString
;
body
+=
type
+
" "
+
name
+
"::get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i) const{
\n
"
;
body
+=
"
\t
return p_"
+
it
->
getName
()
+
"[i];
\n
"
;
body
+=
"}
\n\n
"
;
body
+=
docString
;
body
+=
type
+
" & "
+
name
+
"::get"
+
firstToUpper
(
it
->
getName
())
+
"(size_t i){
\n
"
;
body
+=
"
\t
return p_"
+
it
->
getName
()
+
"[i];
\n
"
;
body
+=
"}
\n\n
"
;
}
}
return
body
;
}
///Get the size of a column
///Get the size of a column
/** @param attr : PAttribute to be used
/** @param attr : PAttribute to be used
* @return corresponding string
* @return corresponding string
...
@@ -437,6 +552,9 @@ std::string ph5_backendTableSource(const PTable & table){
...
@@ -437,6 +552,9 @@ std::string ph5_backendTableSource(const PTable & table){
body
+=
ph5_backendTableSourceRead
(
table
);
body
+=
ph5_backendTableSourceRead
(
table
);
body
+=
ph5_backendTableSourceWrite
(
table
);
body
+=
ph5_backendTableSourceWrite
(
table
);
body
+=
ph5_backendTableSourceSetter
(
table
);
body
+=
ph5_backendTableSourceGetter
(
table
);
body
+=
ph5_backendTableSourceOffset
(
table
);
body
+=
ph5_backendTableSourceOffset
(
table
);
body
+=
ph5_backendTableSourceCompType
(
table
);
body
+=
ph5_backendTableSourceCompType
(
table
);
body
+=
ph5_backendTableSourceDataType
(
table
);
body
+=
ph5_backendTableSourceDataType
(
table
);
...
@@ -454,6 +572,7 @@ std::string ph5_backendTableSource(const PTable & table){
...
@@ -454,6 +572,7 @@ std::string ph5_backendTableSource(const PTable & table){
*/
*/
std
::
string
ph5_backendSource
(
const
PSource
&
source
){
std
::
string
ph5_backendSource
(
const
PSource
&
source
){
std
::
string
body
(
ph5_licenceSaveStr
());
std
::
string
body
(
ph5_licenceSaveStr
());
body
+=
"#include <string.h>
\n
"
;
body
+=
"#include
\"
"
+
eraseExtension
(
source
.
getName
())
+
".h
\"\n\n
"
;
body
+=
"#include
\"
"
+
eraseExtension
(
source
.
getName
())
+
".h
\"\n\n
"
;
const
PVecTable
&
vecTable
=
source
.
getVecTable
();
const
PVecTable
&
vecTable
=
source
.
getVecTable
();
for
(
PVecTable
::
const_iterator
it
(
vecTable
.
begin
());
it
!=
vecTable
.
end
();
++
it
){
for
(
PVecTable
::
const_iterator
it
(
vecTable
.
begin
());
it
!=
vecTable
.
end
();
++
it
){
...
...
src/Representation/representation.cpp
View file @
bf087d72
...
@@ -9,13 +9,14 @@
...
@@ -9,13 +9,14 @@
///Convert a PDimention into a string
///Convert a PDimention into a string
/** @param dim : dimention to be converted
/** @param dim : dimention to be converted
* @param prefix : variable prefix
* @return corresponding string
* @return corresponding string
*/
*/
std
::
string
ph5_dimentionToStr
(
const
PDimention
&
dim
){
std
::
string
ph5_dimentionToStr
(
const
PDimention
&
dim
,
const
std
::
string
&
prefix
){
if
(
dim
.
getIsValue
()){
if
(
dim
.
getIsValue
()){
return
convertToString
(
dim
.
getValue
())
+
"lu"
;
return
convertToString
(
dim
.
getValue
())
+
"lu"
;
}
else
{
}
else
{
return
dim
.
getName
();
return
prefix
+
dim
.
getName
();
}
}
}
}
...
@@ -26,3 +27,19 @@ bool ph5_attributeIsTensor(const PAttribute & attr){
...
@@ -26,3 +27,19 @@ bool ph5_attributeIsTensor(const PAttribute & attr){
return
attr
.
getVecDim
().
size
()
!=
0lu
;
return
attr
.
getVecDim
().
size
()
!=
0lu
;
}
}
///Get the number of elements of an attribute
/** @param attr : attribute to be used
* @return number of elements of the attribute
*/
std
::
string
ph5_getFullAttributeElement
(
const
PAttribute
&
attr
){
std
::
string
body
(
""
);
bool
addMult
(
false
);
const
PVecDim
&
vecDim
=
attr
.
getVecDim
();
for
(
PVecDim
::
const_iterator
it
(
vecDim
.
begin
());
it
!=
vecDim
.
end
();
++
it
){
if
(
addMult
){
body
+=
"*"
;}
body
+=
ph5_dimentionToStr
(
*
it
,
"p_"
);
addMult
=
true
;
}
return
body
;
}
src/Representation/representation.h
View file @
bf087d72
...
@@ -14,7 +14,8 @@ typedef std::vector<PAttribute> PVecAttribute;
...
@@ -14,7 +14,8 @@ typedef std::vector<PAttribute> PVecAttribute;
typedef
std
::
vector
<
PTable
>
PVecTable
;
typedef
std
::
vector
<
PTable
>
PVecTable
;
typedef
std
::
vector
<
PSource
>
PVecSource
;
typedef
std
::
vector
<
PSource
>
PVecSource
;
std
::
string
ph5_dimentionToStr
(
const
PDimention
&
dim
);
std
::
string
ph5_dimentionToStr
(
const
PDimention
&
dim
,
const
std
::
string
&
prefix
=
""
);
bool
ph5_attributeIsTensor
(
const
PAttribute
&
attr
);
bool
ph5_attributeIsTensor
(
const
PAttribute
&
attr
);
std
::
string
ph5_getFullAttributeElement
(
const
PAttribute
&
attr
);
#endif
#endif
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