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
917c2194
Commit
917c2194
authored
13 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
remove default values + roadmap for next steps
parent
fc05d1b4
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
+38
-41
38 additions, 41 deletions
Common/onelab.h
with
38 additions
and
41 deletions
Common/onelab.h
+
38
−
41
View file @
917c2194
...
...
@@ -43,8 +43,9 @@ namespace onelab{
// numbers to force their relative ordering (such numbers could be
// automatically hidden in a GUI).
std
::
string
_name
;
// optional help strings (the short help can serve as a better way
// to display the parameter in a GUI)
// help strings (the short help can serve as a better way to
// display the parameter in a GUI). Should allow richer encoding
// (UTF? HTML?)
std
::
string
_shortHelp
,
_help
;
// client code(s) that use this parameter
std
::
set
<
std
::
string
>
_clients
;
...
...
@@ -52,6 +53,9 @@ namespace onelab{
bool
_changed
;
// should the parameter be visible in the interface
bool
_visible
;
protected:
// optional additional attributes
std
::
map
<
std
::
string
,
std
::
string
>
_attributes
;
public:
parameter
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
shortHelp
=
""
,
const
std
::
string
&
help
=
""
)
...
...
@@ -129,23 +133,20 @@ namespace onelab{
// to make the interface nicer.
class
number
:
public
parameter
{
private:
double
_value
,
_defaultValue
,
_min
,
_max
,
_step
;
double
_value
,
_min
,
_max
,
_step
;
std
::
vector
<
double
>
_choices
;
public:
number
(
const
std
::
string
&
name
=
""
,
double
defaultV
alue
=
0.
,
number
(
const
std
::
string
&
name
=
""
,
double
v
alue
=
0.
,
const
std
::
string
&
shortHelp
=
""
,
const
std
::
string
&
help
=
""
)
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
defaultValue
),
_defaultValue
(
defaultValue
),
_min
(
-
maxNumber
()),
_max
(
maxNumber
()),
_step
(
0.
)
{}
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
value
),
_min
(
-
maxNumber
()),
_max
(
maxNumber
()),
_step
(
0.
)
{}
void
setValue
(
double
value
){
_value
=
value
;
}
void
setDefaultValue
(
double
value
){
_defaultValue
=
value
;
}
void
setMin
(
double
min
){
_min
=
min
;
}
void
setMax
(
double
max
){
_max
=
max
;
}
void
setStep
(
double
step
){
_step
=
step
;
}
void
setChoices
(
std
::
vector
<
double
>
&
choices
){
_choices
=
choices
;
}
std
::
string
getType
()
const
{
return
"number"
;
}
double
getValue
()
const
{
return
_value
;
}
double
getDefaultValue
()
const
{
return
_defaultValue
;
}
double
getMin
()
const
{
return
_min
;
}
double
getMax
()
const
{
return
_max
;
}
double
getStep
()
const
{
return
_step
;
}
...
...
@@ -156,8 +157,6 @@ namespace onelab{
setValue
(
p
.
getValue
());
setChanged
(
true
);
}
if
(
p
.
getDefaultValue
()
&&
p
.
getDefaultValue
()
!=
getDefaultValue
())
setDefaultValue
(
p
.
getDefaultValue
());
if
(
p
.
getMin
()
!=
-
maxNumber
())
setMin
(
p
.
getMin
());
if
(
p
.
getMax
()
!=
maxNumber
())
...
...
@@ -169,8 +168,8 @@ namespace onelab{
{
std
::
ostringstream
sstream
;
sstream
<<
parameter
::
toChar
()
<<
charSep
()
<<
_value
<<
charSep
()
<<
_
defaultValue
<<
charSep
()
<<
_m
in
<<
charSep
()
<<
_
max
<<
charSep
()
<<
_step
<<
charSep
()
<<
_choices
.
size
()
<<
charSep
();
<<
_
min
<<
charSep
()
<<
_m
ax
<<
charSep
()
<<
_
step
<<
charSep
()
<<
_choices
.
size
()
<<
charSep
();
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
sstream
<<
_choices
[
i
]
<<
charSep
();
sstream
<<
getClients
().
size
()
<<
charSep
();
...
...
@@ -188,7 +187,6 @@ namespace onelab{
setHelp
(
getNextToken
(
msg
,
pos
));
setVisible
(
atoi
(
getNextToken
(
msg
,
pos
).
c_str
()));
setValue
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setDefaultValue
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setMin
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setMax
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
setStep
(
atof
(
getNextToken
(
msg
,
pos
).
c_str
()));
...
...
@@ -198,23 +196,26 @@ namespace onelab{
}
};
// The string class.
// The string class. A string has a mutable "type": we do not derive
// specialized classes, because the type should be changeable at
// runtime (e.g. from client-dependent function to onelab-function
// to table of values)
class
string
:
public
parameter
{
private:
std
::
string
_value
;
std
::
string
_defaultValue
;
std
::
vector
<
std
::
string
>
_choices
;
// FIXME add a "type" to interpret the string: file name,
// comma-separated values for a list, hostname, table of numbers,
// client-dependent mathematical expression ("3 sin(X[])"),
// onlab-expression (through mathex?), ...
public:
string
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
defaultV
alue
=
""
,
string
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
v
alue
=
""
,
const
std
::
string
&
shortHelp
=
""
,
const
std
::
string
&
help
=
""
)
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
defaultValue
),
_defaultValue
(
defaultValue
)
{}
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
value
)
{}
void
setValue
(
const
std
::
string
&
value
){
_value
=
value
;
}
void
setDefaultValue
(
const
std
::
string
&
value
){
_defaultValue
=
value
;
}
void
setChoices
(
const
std
::
vector
<
std
::
string
>
&
choices
){
_choices
=
choices
;
}
std
::
string
getType
()
const
{
return
"string"
;
}
const
std
::
string
&
getValue
()
const
{
return
_value
;
}
const
std
::
string
&
getDefaultValue
()
const
{
return
_defaultValue
;
}
const
std
::
vector
<
std
::
string
>
&
getChoices
()
const
{
return
_choices
;
}
void
update
(
const
string
&
p
)
{
...
...
@@ -222,8 +223,6 @@ namespace onelab{
setValue
(
p
.
getValue
());
setChanged
(
true
);
}
if
(
p
.
getDefaultValue
().
size
()
&&
p
.
getDefaultValue
()
!=
getDefaultValue
())
setDefaultValue
(
p
.
getDefaultValue
());
if
(
p
.
getChoices
().
size
())
setChoices
(
p
.
getChoices
());
}
...
...
@@ -231,7 +230,7 @@ namespace onelab{
{
std
::
ostringstream
sstream
;
sstream
<<
parameter
::
toChar
()
<<
charSep
()
<<
sanitize
(
_value
)
<<
charSep
()
<<
sanitize
(
_defaultValue
)
<<
charSep
()
<<
_choices
.
size
()
<<
charSep
();
<<
_choices
.
size
()
<<
charSep
();
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
sstream
<<
sanitize
(
_choices
[
i
])
<<
charSep
();
sstream
<<
getClients
().
size
()
<<
charSep
();
...
...
@@ -249,27 +248,26 @@ namespace onelab{
setHelp
(
getNextToken
(
msg
,
pos
));
setVisible
(
atoi
(
getNextToken
(
msg
,
pos
).
c_str
()));
setValue
(
getNextToken
(
msg
,
pos
));
setDefaultValue
(
getNextToken
(
msg
,
pos
));
_choices
.
resize
(
atoi
(
getNextToken
(
msg
,
pos
).
c_str
()));
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
_choices
[
i
]
=
getNextToken
(
msg
,
pos
);
}
};
// 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
// regions will include union, intersection, etc.
class
region
:
public
parameter
{
private:
std
::
string
_value
,
_defaultValue
;
std
::
string
_value
;
// FIXME: change this into std::set<std::string>
std
::
vector
<
std
::
string
>
_choices
;
public:
region
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
defaultV
alue
=
""
,
region
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
v
alue
=
""
,
const
std
::
string
&
shortHelp
=
""
,
const
std
::
string
&
help
=
""
)
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
defaultValue
),
_defaultValue
(
defaultValue
)
{}
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
value
)
{}
void
setValue
(
const
std
::
string
&
value
){
_value
=
value
;
}
std
::
string
getType
()
const
{
return
"region"
;
}
const
std
::
string
&
getValue
()
const
{
return
_value
;
}
const
std
::
string
&
getDefaultValue
()
const
{
return
_defaultValue
;
}
void
update
(
const
region
&
p
)
{
if
(
p
.
getValue
()
!=
getValue
()){
...
...
@@ -281,7 +279,7 @@ namespace onelab{
{
std
::
ostringstream
sstream
;
sstream
<<
parameter
::
toChar
()
<<
charSep
()
<<
_value
<<
charSep
()
<<
_defaultValue
<<
charSep
()
<<
_choices
.
size
()
<<
charSep
();
<<
_choices
.
size
()
<<
charSep
();
for
(
unsigned
int
i
=
0
;
i
<
_choices
.
size
();
i
++
)
sstream
<<
_choices
[
i
]
<<
charSep
();
sstream
<<
getClients
().
size
()
<<
charSep
();
...
...
@@ -293,19 +291,20 @@ namespace onelab{
};
// The (possibly piece-wise defined on regions) function
// class.
Currently f
unctions are entirely client-dependent: they
//
are just
represented internally as
strings. Again, we might want
//
to specialize in the future to make the interface more refined
.
// class.
F
unctions are entirely client-dependent: they
are just
// represented internally as
onelab strings, defined on onelab
//
regions
.
class
function
:
public
parameter
{
private:
std
::
string
_value
,
_defaultValue
;
// Change this to onelab::string
std
::
string
_value
;
// Change this into std::map<onelab::region, onelab::string>
std
::
map
<
std
::
string
,
std
::
string
>
_pieceWiseValues
;
std
::
vector
<
std
::
string
>
_choices
;
public:
function
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
defaultV
alue
=
""
,
function
(
const
std
::
string
&
name
=
""
,
const
std
::
string
&
v
alue
=
""
,
const
std
::
string
&
shortHelp
=
""
,
const
std
::
string
&
help
=
""
)
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
defaultValue
),
_defaultValue
(
defaultValue
)
{}
:
parameter
(
name
,
shortHelp
,
help
),
_value
(
value
)
{}
void
setValue
(
const
std
::
string
&
value
,
const
std
::
string
&
region
=
""
)
{
if
(
region
.
empty
())
...
...
@@ -328,7 +327,6 @@ namespace onelab{
{
return
_pieceWiseValues
;
}
const
std
::
string
&
getDefaultValue
()
const
{
return
_defaultValue
;
}
void
update
(
const
function
&
p
)
{
if
(
p
.
getValue
()
!=
getValue
()){
...
...
@@ -340,7 +338,6 @@ namespace onelab{
{
std
::
ostringstream
sstream
;
sstream
<<
parameter
::
toChar
()
<<
charSep
()
<<
sanitize
(
_value
)
<<
charSep
()
<<
sanitize
(
_defaultValue
)
<<
charSep
()
<<
_pieceWiseValues
.
size
()
<<
charSep
();
for
(
std
::
map
<
std
::
string
,
std
::
string
>::
const_iterator
it
=
_pieceWiseValues
.
begin
();
it
!=
_pieceWiseValues
.
end
();
it
++
)
...
...
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