Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenVolumeMesh
OpenVolumeMesh
Commits
9744578e
Commit
9744578e
authored
Aug 19, 2019
by
Martin Heistermann
Browse files
experimental: get_property and create_property
parent
0d447e1d
Pipeline
#11806
passed with stage
in 3 minutes and 48 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/OpenVolumeMesh/Core/ResourceManager.hh
View file @
9744578e
...
...
@@ -41,12 +41,17 @@
#include
<vector>
#include
<type_traits>
#include
"../System/Compiler.hh"
#include
"../Config/Export.hh"
#include
"OpenVolumeMeshProperty.hh"
#include
"PropertyHandles.hh"
#include
"TypeName.hh"
#include
"ForwardDeclarations.hh"
#if OVM_CXX_17
#include
<optional>
#endif
namespace
OpenVolumeMesh
{
// Forward declarations
...
...
@@ -141,6 +146,18 @@ public:
template
<
typename
T
,
typename
EntityTag
>
PropertyTT
<
T
,
EntityTag
>
request_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
#if OVM_CXX_17
/** Create new property: if the property already exists, return no value.
*/
template
<
typename
T
,
typename
EntityTag
>
std
::
optional
<
PropertyTT
<
T
,
EntityTag
>>
create_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
/** Get existing property: if the property does not exist, return no value.
*/
template
<
typename
T
,
typename
EntityTag
>
std
::
optional
<
PropertyTT
<
T
,
EntityTag
>>
get_property
(
const
std
::
string
&
_name
=
std
::
string
());
#endif
template
<
class
T
>
VertexPropertyT
<
T
>
request_vertex_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
template
<
class
T
>
EdgePropertyT
<
T
>
request_edge_property
(
const
std
::
string
&
_name
=
std
::
string
(),
const
T
_def
=
T
());
...
...
src/OpenVolumeMesh/Core/ResourceManagerT_impl.hh
View file @
9744578e
...
...
@@ -123,6 +123,28 @@ PropertyTT<T, EntityTag> ResourceManager::request_property(const std::string& _n
return
internal_create_property
<
T
,
EntityTag
>
(
_name
,
_def
);
}
#if OVM_CXX_17
template
<
typename
T
,
typename
EntityTag
>
std
::
optional
<
PropertyTT
<
T
,
EntityTag
>>
ResourceManager
::
create_property
(
const
std
::
string
&
_name
,
const
T
_def
)
{
auto
*
prop
=
internal_find_property
<
T
,
EntityTag
>
(
_name
);
if
(
prop
)
return
{};
return
{
*
internal_create_property
<
T
,
EntityTag
>
(
_name
,
_def
)};
}
template
<
typename
T
,
typename
EntityTag
>
std
::
optional
<
PropertyTT
<
T
,
EntityTag
>>
ResourceManager
::
get_property
(
const
std
::
string
&
_name
)
{
auto
*
prop
=
internal_find_property
<
T
,
EntityTag
>
(
_name
);
if
(
prop
)
return
{
*
prop
};
return
{};
}
#endif
template
<
typename
T
,
class
EntityTag
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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