Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MostafaMollaali
dynamic
Commits
6c5d77d3
Commit
6c5d77d3
authored
5 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[MPL/Component] hasProperty(): check if the prop. exists.
parent
a5af0320
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MaterialLib/MPL/Component.cpp
+5
-0
5 additions, 0 deletions
MaterialLib/MPL/Component.cpp
MaterialLib/MPL/Component.h
+15
-0
15 additions, 0 deletions
MaterialLib/MPL/Component.h
with
20 additions
and
0 deletions
MaterialLib/MPL/Component.cpp
+
5
−
0
View file @
6c5d77d3
...
@@ -34,4 +34,9 @@ Property const& Component::property(PropertyType const& p) const
...
@@ -34,4 +34,9 @@ Property const& Component::property(PropertyType const& p) const
{
{
return
*
_properties
[
p
];
return
*
_properties
[
p
];
}
}
bool
Component
::
hasProperty
(
PropertyType
const
&
p
)
const
{
return
_properties
[
p
]
!=
nullptr
;
}
}
// namespace MaterialPropertyLib
}
// namespace MaterialPropertyLib
This diff is collapsed.
Click to expand it.
MaterialLib/MPL/Component.h
+
15
−
0
View file @
6c5d77d3
...
@@ -34,6 +34,7 @@ public:
...
@@ -34,6 +34,7 @@ public:
/// A get-function for retrieving a certain property.
/// A get-function for retrieving a certain property.
Property
const
&
property
(
PropertyType
const
&
/*p*/
)
const
;
Property
const
&
property
(
PropertyType
const
&
/*p*/
)
const
;
bool
hasProperty
(
PropertyType
const
&
p
)
const
;
template
<
typename
T
>
template
<
typename
T
>
T
value
(
PropertyType
const
p
)
const
T
value
(
PropertyType
const
p
)
const
...
@@ -84,4 +85,18 @@ protected:
...
@@ -84,4 +85,18 @@ protected:
std
::
unique_ptr
<
Component
>
newComponent
(
std
::
string
const
&
component_name
,
std
::
unique_ptr
<
Component
>
newComponent
(
std
::
string
const
&
component_name
,
bool
&
isCustomComponent
);
bool
&
isCustomComponent
);
template
<
typename
Container
>
void
checkRequiredProperties
(
Component
const
&
c
,
Container
const
&
required_properties
)
{
for
(
auto
const
&
p
:
required_properties
)
{
if
(
!
c
.
hasProperty
(
p
))
{
OGS_FATAL
(
"The property '%s' is missing in the component '%s'."
,
property_enum_to_string
[
p
].
c_str
(),
c
.
name
.
c_str
());
}
}
}
}
// namespace MaterialPropertyLib
}
// namespace MaterialPropertyLib
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment