Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stéphane Adjemian
preprocessor
Commits
1de83b7b
Verified
Commit
1de83b7b
authored
1 year ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
Configuration file: simplify handling of GlobalInitFile option
There was some overengineering related to the Hook class.
parent
328e8eef
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Configuration.cc
+6
-45
6 additions, 45 deletions
src/Configuration.cc
src/Configuration.hh
+1
-17
1 addition, 17 deletions
src/Configuration.hh
with
7 additions
and
62 deletions
src/Configuration.cc
+
6
−
45
View file @
1de83b7b
...
...
@@ -35,16 +35,6 @@
#include
<boost/tokenizer.hpp>
#pragma GCC diagnostic pop
Configuration
::
Hook
::
Hook
(
string
global_init_file_arg
)
{
if
(
global_init_file_arg
.
empty
())
{
cerr
<<
"ERROR: The Hook must have a Global Initialization File argument."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
hooks
[
"global_init_file"
]
=
move
(
global_init_file_arg
);
}
Configuration
::
Path
::
Path
(
vector
<
string
>
includepath_arg
)
{
if
(
includepath_arg
.
empty
())
...
...
@@ -170,7 +160,7 @@ Configuration::getConfigFileInfo(const filesystem::path& conffile_option,
}
string
name
,
computerName
,
port
,
userName
,
password
,
remoteDrive
,
remoteDirectory
,
programPath
,
programConfig
,
matlabOctavePath
,
operatingSystem
,
global_init_file
;
programConfig
,
matlabOctavePath
,
operatingSystem
;
vector
<
string
>
includepath
;
int
minCpuNbr
{
0
},
maxCpuNbr
{
0
};
int
numberOfThreadsPerJob
{
1
};
...
...
@@ -189,10 +179,7 @@ Configuration::getConfigFileInfo(const filesystem::path& conffile_option,
if
(
line
==
"[node]"
||
line
==
"[cluster]"
||
line
==
"[hooks]"
||
line
==
"[paths]"
)
{
if
(
!
global_init_file
.
empty
())
// we were just in [hooks]
addHooksConfFileElement
(
global_init_file
);
else
if
(
!
includepath
.
empty
())
if
(
!
includepath
.
empty
())
// we were just in [paths]
addPathsConfFileElement
(
includepath
);
else
...
...
@@ -233,8 +220,7 @@ Configuration::getConfigFileInfo(const filesystem::path& conffile_option,
}
name
=
userName
=
computerName
=
port
=
password
=
remoteDrive
=
remoteDirectory
=
programPath
=
programConfig
=
matlabOctavePath
=
operatingSystem
=
global_init_file
=
""
;
=
programPath
=
programConfig
=
matlabOctavePath
=
operatingSystem
=
""
;
includepath
.
clear
();
minCpuNbr
=
maxCpuNbr
=
0
;
numberOfThreadsPerJob
=
1
;
...
...
@@ -454,9 +440,7 @@ Configuration::getConfigFileInfo(const filesystem::path& conffile_option,
}
}
if
(
!
global_init_file
.
empty
())
addHooksConfFileElement
(
global_init_file
);
else
if
(
!
includepath
.
empty
())
if
(
!
includepath
.
empty
())
addPathsConfFileElement
(
includepath
);
else
addParallelConfFileElement
(
inNode
,
inCluster
,
member_nodes
,
name
,
computerName
,
port
,
minCpuNbr
,
...
...
@@ -467,19 +451,6 @@ Configuration::getConfigFileInfo(const filesystem::path& conffile_option,
configFile
.
close
();
}
void
Configuration
::
addHooksConfFileElement
(
string
global_init_file
)
{
if
(
global_init_file
.
empty
())
{
cerr
<<
"ERROR: The global initialization file must be passed to the GlobalInitFile option."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
else
hooks
.
emplace_back
(
move
(
global_init_file
));
}
void
Configuration
::
addPathsConfFileElement
(
vector
<
string
>
includepath
)
{
...
...
@@ -547,15 +518,6 @@ Configuration::addParallelConfFileElement(bool inNode, bool inCluster,
void
Configuration
::
checkPass
([[
maybe_unused
]]
WarningConsolidation
&
warnings
)
const
{
for
(
bool
global_init_file_declared
{
false
};
const
auto
&
hook
:
hooks
)
for
(
const
auto
&
mapit
:
hook
.
get_hooks
())
if
(
mapit
.
first
==
"global_init_file"
)
if
(
exchange
(
global_init_file_declared
,
true
))
{
cerr
<<
"ERROR: Only one global initialization file may be provided."
<<
endl
;
exit
(
EXIT_FAILURE
);
}
if
(
!
parallel
&&
!
parallel_test
)
return
;
...
...
@@ -723,9 +685,8 @@ Configuration::getIncludePaths() const
void
Configuration
::
writeHooks
(
ostream
&
output
)
const
{
for
(
auto
hook
:
hooks
)
for
(
const
auto
&
mapit
:
hook
.
get_hooks
())
output
<<
"options_."
<<
mapit
.
first
<<
" = '"
<<
mapit
.
second
<<
"';"
<<
endl
;
if
(
!
global_init_file
.
empty
())
output
<<
"options_.global_init_file = '"
<<
global_init_file
<<
"';"
<<
endl
;
}
void
...
...
This diff is collapsed.
Click to expand it.
src/Configuration.hh
+
1
−
17
View file @
1de83b7b
...
...
@@ -39,20 +39,6 @@ public:
private:
using
member_nodes_t
=
map
<
string
,
double
>
;
class
Hook
{
public:
explicit
Hook
(
string
global_init_file_arg
);
[[
nodiscard
]]
map
<
string
,
string
>
get_hooks
()
const
{
return
hooks
;
};
private
:
map
<
string
,
string
>
hooks
;
};
class
Path
{
public:
...
...
@@ -94,15 +80,13 @@ private:
const
string
cluster_name
;
string
firstClusterName
;
//! Hooks
vector
<
Hook
>
hooks
;
string
global_init_file
;
//! Paths
vector
<
Path
>
paths
;
//! Cluster Table
map
<
string
,
Cluster
>
clusters
;
//! Node Map
map
<
string
,
FollowerNode
>
follower_nodes
;
//! Add Hooks
void
addHooksConfFileElement
(
string
global_init_file
);
//! Add Paths
void
addPathsConfFileElement
(
vector
<
string
>
includepath
);
//! Add a FollowerNode or a Cluster object
...
...
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