Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
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
Feliks Kiszkurno
ogs-feliks
Commits
1f61ef03
Commit
1f61ef03
authored
6 years ago
by
Dmitri Naumov
Committed by
renchao.lu
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[PL] Extract duplicate findProcessVariables().
parent
dfe77596
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ProcessLib/Utils/ProcessUtils.cpp
+25
-31
25 additions, 31 deletions
ProcessLib/Utils/ProcessUtils.cpp
with
25 additions
and
31 deletions
ProcessLib/Utils/ProcessUtils.cpp
+
25
−
31
View file @
1f61ef03
...
...
@@ -11,20 +11,17 @@
#include
<iterator>
#include
"ProcessLib/ProcessVariable.h"
namespace
ProcessLib
namespace
{
ProcessVariable
&
find
Process
Variable
(
std
::
vector
<
ProcessVariable
>
const
&
variables
,
BaseLib
::
ConfigTree
const
&
pv_config
,
std
::
string
const
&
tag
)
ProcessLib
::
ProcessVariable
&
findVariable
ByName
(
std
::
vector
<
ProcessLib
::
ProcessVariable
>
const
&
variables
,
std
::
string
const
&
name
,
std
::
string
const
&
tag
)
{
// Find process variable name in process config.
//! \ogs_file_special
std
::
string
const
name
=
pv_config
.
getConfigParameter
<
std
::
string
>
(
tag
);
// Find corresponding variable by name.
auto
variable
=
std
::
find_if
(
variables
.
cbegin
(),
variables
.
cend
(),
[
&
name
](
ProcessVariable
const
&
v
)
{
return
v
.
getName
()
==
name
;
});
auto
variable
=
std
::
find_if
(
variables
.
cbegin
(),
variables
.
cend
(),
[
&
name
](
ProcessLib
::
ProcessVariable
const
&
v
)
{
return
v
.
getName
()
==
name
;
});
if
(
variable
==
variables
.
end
())
{
...
...
@@ -37,7 +34,20 @@ ProcessVariable& findProcessVariable(
variable
->
getName
().
c_str
(),
tag
.
c_str
());
// Const cast is needed because of variables argument constness.
return
const_cast
<
ProcessVariable
&>
(
*
variable
);
return
const_cast
<
ProcessLib
::
ProcessVariable
&>
(
*
variable
);
}
}
// namespace
namespace
ProcessLib
{
ProcessVariable
&
findProcessVariable
(
std
::
vector
<
ProcessVariable
>
const
&
variables
,
BaseLib
::
ConfigTree
const
&
pv_config
,
std
::
string
const
&
tag
)
{
// Find process variable name in process config.
//! \ogs_file_special
std
::
string
const
name
=
pv_config
.
getConfigParameter
<
std
::
string
>
(
tag
);
return
findVariableByName
(
variables
,
name
,
tag
);
}
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>
findProcessVariables
(
...
...
@@ -68,6 +78,7 @@ std::vector<std::reference_wrapper<ProcessVariable>> findProcessVariables(
{
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>
vars
;
//! \ogs_file_special
auto
var_names
=
pv_config
.
getConfigParameterList
<
std
::
string
>
(
tag
);
if
(
var_names
.
empty
())
...
...
@@ -77,24 +88,7 @@ std::vector<std::reference_wrapper<ProcessVariable>> findProcessVariables(
for
(
std
::
string
const
&
var_name
:
var_names
)
{
auto
variable
=
std
::
find_if
(
variables
.
cbegin
(),
variables
.
cend
(),
[
&
var_name
](
ProcessVariable
const
&
v
)
{
return
v
.
getName
()
==
var_name
;
});
if
(
variable
==
variables
.
end
())
{
OGS_FATAL
(
"Could not find process variable '%s' in the provided "
"variables "
"list for config tag <%s>."
,
var_name
.
c_str
(),
tag
.
c_str
());
}
DBUG
(
"Found process variable
\'
%s
\'
for config tag <%s>."
,
variable
->
getName
().
c_str
(),
tag
.
c_str
());
vars
.
emplace_back
(
const_cast
<
ProcessVariable
&>
(
*
variable
));
vars
.
push_back
(
findVariableByName
(
variables
,
var_name
,
tag
));
cached_var_names
.
push_back
(
var_name
);
}
...
...
@@ -106,4 +100,4 @@ std::vector<std::reference_wrapper<ProcessVariable>> findProcessVariables(
return
vars
;
}
}
// ProcessLib
}
//
namespace
ProcessLib
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