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
3282f30f
Commit
3282f30f
authored
13 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
cleanup
parent
3728935c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Common/onelab.h
+44
-41
44 additions, 41 deletions
Common/onelab.h
with
44 additions
and
41 deletions
Common/onelab.h
+
44
−
41
View file @
3282f30f
...
@@ -53,8 +53,7 @@ namespace onelab{
...
@@ -53,8 +53,7 @@ namespace onelab{
std
::
string
_help
;
std
::
string
_help
;
// clients that use this parameter
// clients that use this parameter
std
::
set
<
std
::
string
>
_clients
;
std
::
set
<
std
::
string
>
_clients
;
// flag to check if the parameter has been changed since the last
// flag to check if the parameter has been changed since the last run()
// run()
bool
_changed
;
bool
_changed
;
// should the parameter be visible in the interface?
// should the parameter be visible in the interface?
bool
_visible
;
bool
_visible
;
...
@@ -125,14 +124,24 @@ namespace onelab{
...
@@ -125,14 +124,24 @@ namespace onelab{
static
double
maxNumber
()
{
return
1e200
;
}
static
double
maxNumber
()
{
return
1e200
;
}
static
std
::
string
version
()
{
return
"1.0"
;
}
static
std
::
string
version
()
{
return
"1.0"
;
}
static
std
::
string
getNextToken
(
const
std
::
string
&
msg
,
static
std
::
string
getNextToken
(
const
std
::
string
&
msg
,
std
::
string
::
size_type
&
first
)
std
::
string
::
size_type
&
first
,
char
separator
=
charSep
())
{
{
if
(
first
==
std
::
string
::
npos
)
return
""
;
if
(
first
==
std
::
string
::
npos
)
return
""
;
std
::
string
::
size_type
last
=
msg
.
find_first_of
(
charSep
()
,
first
);
std
::
string
::
size_type
last
=
msg
.
find_first_of
(
separator
,
first
);
std
::
string
next
=
msg
.
substr
(
first
,
last
-
first
);
std
::
string
next
=
msg
.
substr
(
first
,
last
-
first
);
first
=
(
last
==
std
::
string
::
npos
)
?
last
:
last
+
1
;
first
=
(
last
==
std
::
string
::
npos
)
?
last
:
last
+
1
;
return
next
;
return
next
;
}
}
static
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
msg
,
char
separator
=
charSep
())
{
std
::
vector
<
std
::
string
>
out
;
std
::
string
::
size_type
first
=
0
;
while
(
first
!=
std
::
string
::
npos
)
out
.
push_back
(
getNextToken
(
msg
,
first
,
separator
));
return
out
;
}
std
::
string
sanitize
(
const
std
::
string
&
in
)
const
std
::
string
sanitize
(
const
std
::
string
&
in
)
const
{
{
std
::
string
out
(
in
);
std
::
string
out
(
in
);
...
@@ -198,11 +207,9 @@ namespace onelab{
...
@@ -198,11 +207,9 @@ namespace onelab{
}
}
};
};
// The number class. Numbers are stored internally as double
// The number class. Numbers are stored internally as double precision real
// precision real numbers. Currently all more complicated types
// numbers. All more complicated types (complex numbers, vectors, etc.) are
// (complex numbers, vectors, etc.) are supposed to be encapsulated
// supposed to be either exchanged as strings or encapsulated in functions.
// in functions. We might add more base types in the future to make
// the interface more expressive.
class
number
:
public
parameter
{
class
number
:
public
parameter
{
private:
private:
double
_value
,
_min
,
_max
,
_step
;
double
_value
,
_min
,
_max
,
_step
;
...
@@ -265,12 +272,11 @@ namespace onelab{
...
@@ -265,12 +272,11 @@ namespace onelab{
};
};
// The string class. A string has a mutable "kind": we do not derive
// The string class. A string has a mutable "kind": we do not derive
// specialized classes, because the kind should be changeable at
// specialized classes, because the kind should be changeable at runtime
// runtime (e.g. from a client-dependent mathematical expression to
// (e.g. from a client-dependent mathematical expression to a table of
// a table of values). Possible kinds: generic, filename, hostname,
// values). Kinds currently recognized by Gmsh are: "file". Possible kinds
// client-dependent mathematical expression, comma-separated list of
// could be "complex", "matrix m n", "hostname", client-dependent mathematical
// values, matlab matrix, onelab mathematical expression (through
// expression, onelab mathematical expression (through mathex?), ...
// mathex?), ...
class
string
:
public
parameter
{
class
string
:
public
parameter
{
private:
private:
std
::
string
_value
,
_kind
;
std
::
string
_value
,
_kind
;
...
@@ -327,8 +333,8 @@ namespace onelab{
...
@@ -327,8 +333,8 @@ namespace onelab{
};
};
// The region class. A region can be any kind of geometrical entity,
// The region class. A region can be any kind of geometrical entity,
// represented as identifiers of physical regions. Operations on
// represented as identifiers of physical regions. Operations on
regions will
//
regions will
include union, intersection, etc.
// include union, intersection, etc.
class
region
:
public
parameter
{
class
region
:
public
parameter
{
private:
private:
std
::
set
<
std
::
string
>
_value
;
std
::
set
<
std
::
string
>
_value
;
...
@@ -368,10 +374,9 @@ namespace onelab{
...
@@ -368,10 +374,9 @@ namespace onelab{
}
}
};
};
// The (possibly piece-wise defined on regions) function
// The (possibly piece-wise defined on regions) function class. Functions are
// class. Functions are entirely client-dependent: they are just
// entirely client-dependent: they are just represented internally as onelab
// represented internally as onelab strings, defined on onelab
// strings, defined on onelab regions.
// regions.
class
function
:
public
parameter
{
class
function
:
public
parameter
{
private:
private:
std
::
string
_value
;
std
::
string
_value
;
...
@@ -430,18 +435,17 @@ namespace onelab{
...
@@ -430,18 +435,17 @@ namespace onelab{
}
}
};
};
// The parameter space, i.e., the set of parameters stored and
// The parameter space, i.e., the set of parameters stored and
handled by the
//
handled by the
onelab server.
// onelab server.
class
parameterSpace
{
class
parameterSpace
{
private:
private:
std
::
set
<
number
*
,
parameterLessThan
>
_numbers
;
std
::
set
<
number
*
,
parameterLessThan
>
_numbers
;
std
::
set
<
string
*
,
parameterLessThan
>
_strings
;
std
::
set
<
string
*
,
parameterLessThan
>
_strings
;
std
::
set
<
region
*
,
parameterLessThan
>
_regions
;
std
::
set
<
region
*
,
parameterLessThan
>
_regions
;
std
::
set
<
function
*
,
parameterLessThan
>
_functions
;
std
::
set
<
function
*
,
parameterLessThan
>
_functions
;
// set a parameter in the parameter space; if it already exists,
// set a parameter in the parameter space; if it already exists, update it
// update it (adding new clients if necessary). This needs to be
// (adding new clients if necessary). This needs to be locked to avoid race
// locked to avoid race conditions when several clients try to set
// conditions when several clients try to set a parameter at the same time.
// a parameter at the same time.
template
<
class
T
>
bool
_set
(
const
T
&
p
,
const
std
::
string
&
client
,
template
<
class
T
>
bool
_set
(
const
T
&
p
,
const
std
::
string
&
client
,
std
::
set
<
T
*
,
parameterLessThan
>
&
ps
)
std
::
set
<
T
*
,
parameterLessThan
>
&
ps
)
{
{
...
@@ -457,11 +461,10 @@ namespace onelab{
...
@@ -457,11 +461,10 @@ namespace onelab{
}
}
return
true
;
return
true
;
}
}
// get the parameter matching the given name, or all the
// get the parameter matching the given name, or all the parameters in the
// parameters in the category if no name is given. If we find a
// category if no name is given. If we find a given parameter by name, we
// given parameter by name, we add the client requesting the
// add the client requesting the parameter to the list of clients for this
// parameter to the list of clients for this parameter. This also
// parameter. This also needs to be locked.
// needs to be locked.
template
<
class
T
>
bool
_get
(
std
::
vector
<
T
>
&
p
,
const
std
::
string
&
name
,
template
<
class
T
>
bool
_get
(
std
::
vector
<
T
>
&
p
,
const
std
::
string
&
name
,
const
std
::
string
&
client
,
const
std
::
string
&
client
,
std
::
set
<
T
*
,
parameterLessThan
>
&
ps
)
std
::
set
<
T
*
,
parameterLessThan
>
&
ps
)
...
@@ -532,8 +535,8 @@ namespace onelab{
...
@@ -532,8 +535,8 @@ namespace onelab{
if
((
*
it
)
->
hasClient
(
client
))
return
true
;
if
((
*
it
)
->
hasClient
(
client
))
return
true
;
return
false
;
return
false
;
}
}
// check if some parameters have changed (optionnally only check
// check if some parameters have changed (optionnally only check
the
//
the
parameters that depend on a given client)
// parameters that depend on a given client)
bool
getChanged
(
const
std
::
string
&
client
=
""
)
const
bool
getChanged
(
const
std
::
string
&
client
=
""
)
const
{
{
std
::
set
<
parameter
*>
ps
;
std
::
set
<
parameter
*>
ps
;
...
@@ -554,8 +557,8 @@ namespace onelab{
...
@@ -554,8 +557,8 @@ namespace onelab{
if
(
client
.
empty
()
||
(
*
it
)
->
hasClient
(
client
))
if
(
client
.
empty
()
||
(
*
it
)
->
hasClient
(
client
))
(
*
it
)
->
setChanged
(
changed
);
(
*
it
)
->
setChanged
(
changed
);
}
}
// serialize the parameter space (optinally only serialize those
// serialize the parameter space (optinally only serialize those
parameters
//
parameters
that depend on the given client)
// that depend on the given client)
std
::
string
toChar
(
const
std
::
string
&
client
=
""
)
const
std
::
string
toChar
(
const
std
::
string
&
client
=
""
)
const
{
{
std
::
string
s
;
std
::
string
s
;
...
@@ -567,9 +570,9 @@ namespace onelab{
...
@@ -567,9 +570,9 @@ namespace onelab{
}
}
};
};
// The onelab client: a class that communicates with the onelab
// The onelab client: a class that communicates with the onelab
server. Each
//
server. Each
client should be derived from this one. A client can
// client should be derived from this one. A client can
be understood as "one
//
be understood as "one
simulation step in a complex computation".
// simulation step in a complex computation".
class
client
{
class
client
{
protected:
protected:
// the name of the client
// the name of the client
...
@@ -606,8 +609,8 @@ namespace onelab{
...
@@ -606,8 +609,8 @@ namespace onelab{
virtual
bool
get
(
std
::
vector
<
function
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
virtual
bool
get
(
std
::
vector
<
function
>
&
ps
,
const
std
::
string
&
name
=
""
)
=
0
;
};
};
// The onelab server: a singleton that stores the parameter space
// The onelab server: a singleton that stores the parameter space
and
//
and
interacts with onelab clients.
// interacts with onelab clients.
class
server
{
class
server
{
private:
private:
// the unique server (singleton behaviour due to the "static" specifier)
// the unique server (singleton behaviour due to the "static" specifier)
...
...
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