Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
b7ea71f5
Commit
b7ea71f5
authored
Jun 20, 2021
by
Martin Schneider
Browse files
[metadata] Add possibility to hide template arguments for class names
parent
db72ab8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
dumux/common/metadata.hh
View file @
b7ea71f5
...
...
@@ -84,29 +84,35 @@ class Metadata {
public:
template
<
class
TypeTag
,
DiffMethod
diffmethod
,
bool
isImplicit
>
static
void
collectMetaData
(
const
FVAssembler
<
TypeTag
,
diffmethod
,
isImplicit
>&
a
)
static
void
collectMetaData
(
const
FVAssembler
<
TypeTag
,
diffmethod
,
isImplicit
>&
a
,
bool
hideTemplates
=
true
)
{
auto
&
obj
=
getTree
()[
"Assembler"
];
obj
[
"Type"
]
=
Dune
::
className
(
a
);
obj
[
"Type"
]
=
className
_
(
a
,
hideTemplates
);
obj
[
"Stationary"
]
=
a
.
isStationaryProblem
()
?
"true"
:
"false"
;
}
template
<
class
GridGeometry
>
static
auto
collectMetaData
(
const
GridGeometry
&
gg
)
static
auto
collectMetaData
(
const
GridGeometry
&
gg
,
bool
hideTemplates
=
true
)
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
isGridGeometry
())(
gg
))
::
value
,
void
>
{
auto
&
obj
=
getTree
()[
"GridGeometry"
];
obj
[
"Type"
]
=
Dune
::
className
(
gg
);
obj
[
"GridView"
]
=
Dune
::
className
(
gg
.
gridView
());
obj
[
"Type"
]
=
className
_
(
gg
,
hideTemplates
);
obj
[
"GridView"
]
[
"Type"
]
=
className
_
(
gg
.
gridView
()
,
hideTemplates
);
obj
[
"IsPeriodic"
]
=
gg
.
isPeriodic
()
?
"true"
:
"false"
;
obj
[
"DiscretisationMethod"
]
=
GridGeometry
::
discMethod
;
obj
[
"MaxElementStencilSize"
]
=
GridGeometry
::
maxElementStencilSize
;
obj
[
"NumScvs"
]
=
gg
.
numScv
();
obj
[
"NumScvfs"
]
=
gg
.
numScvf
();
obj
[
"SumBoundaryScvfs"
]
=
gg
.
numBoundaryScvf
();
obj
[
"NumDofs"
]
=
gg
.
numDofs
();
}
template
<
class
GridVariables
>
static
auto
collectMetaData
(
const
GridVariables
&
gv
)
static
auto
collectMetaData
(
const
GridVariables
&
gv
,
bool
hideTemplates
=
true
)
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
isGridVariables
())(
gv
))
::
value
,
void
>
{
auto
&
obj
=
getTree
()[
"GridVariables"
];
obj
[
"Type"
]
=
Dune
::
className
(
gv
);
obj
[
"Type"
]
=
className
_
(
gv
,
hideTemplates
);
}
//! prints json tree
...
...
@@ -124,6 +130,27 @@ public:
return
parser_
;
}
private:
template
<
class
T
>
static
std
::
string
className_
(
const
T
&
c
,
bool
hideTemplates
)
{
return
hideTemplates
?
hideTemplateArguments_
(
Dune
::
className
(
c
))
:
Dune
::
className
(
c
);
}
static
std
::
string
hideTemplateArguments_
(
std
::
string
&&
s
)
{
std
::
size_t
first
=
s
.
find
(
"<"
);
std
::
size_t
last
=
s
.
find_last_of
(
">"
);
if
(
first
!=
std
::
string
::
npos
&&
last
!=
std
::
string
::
npos
)
s
.
replace
(
first
,
last
-
first
+
1
,
"<...>"
);
s
.
erase
(
std
::
unique
(
std
::
begin
(
s
),
std
::
end
(
s
),
[](
unsigned
char
a
,
unsigned
char
b
){
return
std
::
isspace
(
a
)
&&
std
::
isspace
(
b
);}),
std
::
end
(
s
));
return
std
::
move
(
s
);
}
};
}
// end namespace Dumux
...
...
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