Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
279b7c4f
Commit
279b7c4f
authored
13 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
more const goodness
parent
660f11b4
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
Common/onelab.h
+41
-31
41 additions, 31 deletions
Common/onelab.h
with
41 additions
and
31 deletions
Common/onelab.h
+
41
−
31
View file @
279b7c4f
...
@@ -413,14 +413,20 @@ namespace onelab{
...
@@ -413,14 +413,20 @@ namespace onelab{
// set a parameter in the parameter space; if it already exists,
// set a parameter in the parameter space; if it already exists,
// update it (adding new clients if necessary). This needs to be
// update it (adding new clients if necessary). This needs to be
// locked to avoid race conditions when several clients try to set
// locked to avoid race conditions when several clients try to set
// a parameter at the same time
// a parameter at the same time.
template
<
class
T
>
bool
_set
(
T
&
p
,
std
::
set
<
T
*
,
parameterLessThan
>
&
ps
)
template
<
class
T
>
bool
_set
(
const
T
&
p
,
const
std
::
string
&
client
,
std
::
set
<
T
*
,
parameterLessThan
>
&
ps
)
{
{
typename
std
::
set
<
T
*
,
parameterLessThan
>::
iterator
it
=
ps
.
find
(
&
p
);
typename
std
::
set
<
T
*
,
parameterLessThan
>::
iterator
it
=
ps
.
find
(
(
T
*
)
&
p
);
if
(
it
!=
ps
.
end
())
if
(
it
!=
ps
.
end
())
{
(
*
it
)
->
update
(
p
);
(
*
it
)
->
update
(
p
);
else
if
(
client
.
size
())
(
*
it
)
->
addClient
(
client
);
ps
.
insert
(
new
T
(
p
));
}
else
{
T
*
newp
=
new
T
(
p
);
if
(
client
.
size
())
newp
->
addClient
(
client
);
ps
.
insert
(
newp
);
}
return
true
;
return
true
;
}
}
// get the parameter matching the given name, or all the
// get the parameter matching the given name, or all the
...
@@ -469,10 +475,14 @@ namespace onelab{
...
@@ -469,10 +475,14 @@ namespace onelab{
_regions
.
clear
();
_regions
.
clear
();
_functions
.
clear
();
_functions
.
clear
();
}
}
bool
set
(
number
&
p
){
return
_set
(
p
,
_numbers
);
}
bool
set
(
const
number
&
p
,
bool
set
(
string
&
p
){
return
_set
(
p
,
_strings
);
}
const
std
::
string
&
client
=
""
){
return
_set
(
p
,
client
,
_numbers
);
}
bool
set
(
region
&
p
){
return
_set
(
p
,
_regions
);
}
bool
set
(
const
string
&
p
,
bool
set
(
function
&
p
){
return
_set
(
p
,
_functions
);
}
const
std
::
string
&
client
=
""
){
return
_set
(
p
,
client
,
_strings
);
}
bool
set
(
const
region
&
p
,
const
std
::
string
&
client
=
""
){
return
_set
(
p
,
client
,
_regions
);
}
bool
set
(
const
function
&
p
,
const
std
::
string
&
client
=
""
){
return
_set
(
p
,
client
,
_functions
);
}
bool
get
(
std
::
vector
<
number
>
&
ps
,
const
std
::
string
&
name
=
""
,
bool
get
(
std
::
vector
<
number
>
&
ps
,
const
std
::
string
&
name
=
""
,
const
std
::
string
&
client
=
""
){
return
_get
(
ps
,
name
,
client
,
_numbers
);
}
const
std
::
string
&
client
=
""
){
return
_get
(
ps
,
name
,
client
,
_numbers
);
}
bool
get
(
std
::
vector
<
string
>
&
ps
,
const
std
::
string
&
name
=
""
,
bool
get
(
std
::
vector
<
string
>
&
ps
,
const
std
::
string
&
name
=
""
,
...
@@ -482,7 +492,7 @@ namespace onelab{
...
@@ -482,7 +492,7 @@ namespace onelab{
bool
get
(
std
::
vector
<
function
>
&
ps
,
const
std
::
string
&
name
=
""
,
bool
get
(
std
::
vector
<
function
>
&
ps
,
const
std
::
string
&
name
=
""
,
const
std
::
string
&
client
=
""
){
return
_get
(
ps
,
name
,
client
,
_functions
);
}
const
std
::
string
&
client
=
""
){
return
_get
(
ps
,
name
,
client
,
_functions
);
}
// check if at least one parameter depends on the given client
// check if at least one parameter depends on the given client
bool
hasClient
(
const
std
::
string
&
client
)
bool
hasClient
(
const
std
::
string
&
client
)
const
{
{
std
::
set
<
parameter
*>
ps
;
std
::
set
<
parameter
*>
ps
;
_getAllParameters
(
ps
);
_getAllParameters
(
ps
);
...
@@ -492,7 +502,7 @@ namespace onelab{
...
@@ -492,7 +502,7 @@ namespace onelab{
}
}
// check if some parameters have changed (optionnally only check
// check if some parameters have changed (optionnally only check
// the parameters that depend on a given client)
// the parameters that depend on a given client)
bool
getChanged
(
const
std
::
string
&
client
=
""
)
bool
getChanged
(
const
std
::
string
&
client
=
""
)
const
{
{
std
::
set
<
parameter
*>
ps
;
std
::
set
<
parameter
*>
ps
;
_getAllParameters
(
ps
);
_getAllParameters
(
ps
);
...
@@ -554,10 +564,10 @@ namespace onelab{
...
@@ -554,10 +564,10 @@ namespace onelab{
virtual
void
sendMergeFileRequest
(
const
std
::
string
&
msg
){}
virtual
void
sendMergeFileRequest
(
const
std
::
string
&
msg
){}
virtual
void
sendParseStringRequest
(
const
std
::
string
&
msg
){}
virtual
void
sendParseStringRequest
(
const
std
::
string
&
msg
){}
virtual
void
sendVertexArray
(
const
std
::
string
&
msg
){}
virtual
void
sendVertexArray
(
const
std
::
string
&
msg
){}
virtual
bool
set
(
number
&
p
)
=
0
;
virtual
bool
set
(
const
number
&
p
)
=
0
;
virtual
bool
set
(
string
&
p
)
=
0
;
virtual
bool
set
(
const
string
&
p
)
=
0
;
virtual
bool
set
(
region
&
p
)
=
0
;
virtual
bool
set
(
const
region
&
p
)
=
0
;
virtual
bool
set
(
function
&
p
)
=
0
;
virtual
bool
set
(
const
function
&
p
)
=
0
;
virtual
bool
get
(
std
::
vector
<
number
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
virtual
bool
get
(
std
::
vector
<
number
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
virtual
bool
get
(
std
::
vector
<
string
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
virtual
bool
get
(
std
::
vector
<
string
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
virtual
bool
get
(
std
::
vector
<
region
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
virtual
bool
get
(
std
::
vector
<
region
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
...
@@ -585,7 +595,10 @@ namespace onelab{
...
@@ -585,7 +595,10 @@ namespace onelab{
return
_server
;
return
_server
;
}
}
void
clear
(){
_parameterSpace
.
clear
();
}
void
clear
(){
_parameterSpace
.
clear
();
}
template
<
class
T
>
bool
set
(
T
&
p
){
return
_parameterSpace
.
set
(
p
);
}
template
<
class
T
>
bool
set
(
const
T
&
p
,
const
std
::
string
&
client
=
""
)
{
return
_parameterSpace
.
set
(
p
,
client
);
}
template
<
class
T
>
bool
get
(
std
::
vector
<
T
>
&
ps
,
const
std
::
string
&
name
=
""
,
template
<
class
T
>
bool
get
(
std
::
vector
<
T
>
&
ps
,
const
std
::
string
&
name
=
""
,
const
std
::
string
&
client
=
""
)
const
std
::
string
&
client
=
""
)
{
{
...
@@ -621,10 +634,9 @@ namespace onelab{
...
@@ -621,10 +634,9 @@ namespace onelab{
private:
private:
// the pointer to the server
// the pointer to the server
server
*
_server
;
server
*
_server
;
template
<
class
T
>
bool
_set
(
T
&
p
)
template
<
class
T
>
bool
_set
(
const
T
&
p
)
{
{
p
.
addClient
(
_name
);
_server
->
set
(
p
,
_name
);
_server
->
set
(
p
);
return
true
;
return
true
;
}
}
template
<
class
T
>
bool
_get
(
std
::
vector
<
T
>
&
ps
,
template
<
class
T
>
bool
_get
(
std
::
vector
<
T
>
&
ps
,
...
@@ -640,10 +652,10 @@ namespace onelab{
...
@@ -640,10 +652,10 @@ namespace onelab{
_server
->
registerClient
(
this
);
_server
->
registerClient
(
this
);
}
}
virtual
~
localClient
(){}
virtual
~
localClient
(){}
virtual
bool
set
(
number
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
number
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
string
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
string
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
function
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
function
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
region
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
region
&
p
){
return
_set
(
p
);
}
virtual
bool
get
(
std
::
vector
<
number
>
&
ps
,
virtual
bool
get
(
std
::
vector
<
number
>
&
ps
,
const
std
::
string
&
name
=
""
){
return
_get
(
ps
,
name
);
}
const
std
::
string
&
name
=
""
){
return
_get
(
ps
,
name
);
}
virtual
bool
get
(
std
::
vector
<
string
>
&
ps
,
virtual
bool
get
(
std
::
vector
<
string
>
&
ps
,
...
@@ -688,10 +700,9 @@ namespace onelab{
...
@@ -688,10 +700,9 @@ namespace onelab{
std
::
string
_serverAddress
;
std
::
string
_serverAddress
;
// underlying GmshClient
// underlying GmshClient
GmshClient
*
_gmshClient
;
GmshClient
*
_gmshClient
;
template
<
class
T
>
bool
_set
(
T
&
p
)
template
<
class
T
>
bool
_set
(
const
T
&
p
)
{
{
if
(
!
_gmshClient
)
return
false
;
if
(
!
_gmshClient
)
return
false
;
p
.
addClient
(
_name
);
std
::
string
msg
=
p
.
toChar
();
std
::
string
msg
=
p
.
toChar
();
_gmshClient
->
SendMessage
(
GmshSocket
::
GMSH_PARAMETER
,
msg
.
size
(),
&
msg
[
0
]);
_gmshClient
->
SendMessage
(
GmshSocket
::
GMSH_PARAMETER
,
msg
.
size
(),
&
msg
[
0
]);
return
true
;
return
true
;
...
@@ -702,7 +713,6 @@ namespace onelab{
...
@@ -702,7 +713,6 @@ namespace onelab{
ps
.
clear
();
ps
.
clear
();
if
(
!
_gmshClient
)
return
false
;
if
(
!
_gmshClient
)
return
false
;
T
p
(
name
);
T
p
(
name
);
p
.
addClient
(
_name
);
std
::
string
msg
=
p
.
toChar
();
std
::
string
msg
=
p
.
toChar
();
_gmshClient
->
SendMessage
(
GmshSocket
::
GMSH_PARAMETER_QUERY
,
msg
.
size
(),
&
msg
[
0
]);
_gmshClient
->
SendMessage
(
GmshSocket
::
GMSH_PARAMETER_QUERY
,
msg
.
size
(),
&
msg
[
0
]);
while
(
1
){
while
(
1
){
...
@@ -767,10 +777,10 @@ namespace onelab{
...
@@ -767,10 +777,10 @@ namespace onelab{
}
}
GmshClient
*
getGmshClient
(){
return
_gmshClient
;
}
GmshClient
*
getGmshClient
(){
return
_gmshClient
;
}
virtual
bool
isNetworkClient
(){
return
true
;
}
virtual
bool
isNetworkClient
(){
return
true
;
}
virtual
bool
set
(
number
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
number
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
string
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
string
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
function
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
function
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
region
&
p
){
return
_set
(
p
);
}
virtual
bool
set
(
const
region
&
p
){
return
_set
(
p
);
}
virtual
bool
get
(
std
::
vector
<
number
>
&
ps
,
virtual
bool
get
(
std
::
vector
<
number
>
&
ps
,
const
std
::
string
&
name
=
""
){
return
_get
(
ps
,
name
);
}
const
std
::
string
&
name
=
""
){
return
_get
(
ps
,
name
);
}
virtual
bool
get
(
std
::
vector
<
string
>
&
ps
,
virtual
bool
get
(
std
::
vector
<
string
>
&
ps
,
...
...
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