Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Pour information : coupure de la forge ce matin entre 6h45 et 7h05 pour une mise à jour de sécurité
Open sidebar
Gauthier Quesnel
irritator
Commits
1805243f
Commit
1805243f
authored
Dec 06, 2020
by
Gauthier Quesnel
Browse files
core: rename new dispatch function
parent
462990a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/gui/node-editor.cpp
View file @
1805243f
...
...
@@ -559,7 +559,7 @@ struct copier
auto
*
mdl
=
sim
.
models
.
try_to_get
(
c_models
[
i
].
src
);
auto
*
mdl_id_dst
=
&
c_models
[
i
].
dst
;
auto
ret
=
sim
.
dispatch
_2
(
auto
ret
=
sim
.
dispatch
(
mdl
->
type
,
[
this
,
&
sim
,
mdl
,
&
mdl_id_dst
]
<
typename
DynamicsM
>
(
DynamicsM
&
dynamics_models
)
->
status
{
...
...
@@ -2036,7 +2036,7 @@ editor::show_model_dynamics(model& mdl) noexcept
ImGui
::
PopItemWidth
();
if
(
simulation_show_value
&&
st
!=
editor_status
::
editing
)
{
sim
.
dispatch
_2
(
mdl
.
type
,
[
&
](
const
auto
&
d_array
)
{
sim
.
dispatch
(
mdl
.
type
,
[
&
](
const
auto
&
d_array
)
{
const
auto
&
dyn
=
d_array
.
get
(
mdl
.
id
);
add_input_attribute
(
*
this
,
dyn
);
ImGui
::
PushItemWidth
(
120.0
f
);
...
...
@@ -2045,7 +2045,7 @@ editor::show_model_dynamics(model& mdl) noexcept
add_output_attribute
(
*
this
,
dyn
);
});
}
else
{
sim
.
dispatch
_2
(
mdl
.
type
,
[
&
](
auto
&
d_array
)
{
sim
.
dispatch
(
mdl
.
type
,
[
&
](
auto
&
d_array
)
{
auto
&
dyn
=
d_array
.
get
(
mdl
.
id
);
add_input_attribute
(
*
this
,
dyn
);
ImGui
::
PushItemWidth
(
120.0
f
);
...
...
@@ -2107,7 +2107,7 @@ show_tooltip(editor& ed, const model& mdl, const model_id id)
mdl
.
tl
,
mdl
.
tn
);
auto
ret
=
ed
.
sim
.
dispatch
_2
(
auto
ret
=
ed
.
sim
.
dispatch
(
mdl
.
type
,
[
&
]
<
typename
DynamicsModels
>
(
DynamicsModels
&
dyn_models
)
{
using
Dynamics
=
typename
DynamicsModels
::
value_type
;
if
constexpr
(
is_detected_v
<
has_input_port_t
,
Dynamics
>
)
...
...
@@ -2230,7 +2230,7 @@ editor::show_top() noexcept
status
add_popup_menuitem
(
editor
&
ed
,
dynamics_type
type
,
model_id
*
new_model
)
{
return
ed
.
sim
.
dispatch
_2
(
type
,
[
&
](
auto
&
d_array
)
{
return
ed
.
sim
.
dispatch
(
type
,
[
&
](
auto
&
d_array
)
{
if
(
ImGui
::
MenuItem
(
dynamics_type_names
[
static_cast
<
i8
>
(
type
)]))
{
if
(
!
ed
.
sim
.
models
.
can_alloc
(
1
)
||
!
d_array
.
can_alloc
(
1
))
return
status
::
data_array_not_enough_memory
;
...
...
lib/include/irritator/core.hpp
View file @
1805243f
...
...
@@ -5391,7 +5391,7 @@ struct simulation
constexpr
sz
e
=
dynamics_type_size
();
for
(;
i
!=
e
;
++
i
)
if
(
auto
ret
=
dispatch
_2
(
static_cast
<
dynamics_type
>
(
i
),
f
);
if
(
auto
ret
=
dispatch
(
static_cast
<
dynamics_type
>
(
i
),
f
);
is_bad
(
ret
))
return
ret
;
...
...
@@ -5515,9 +5515,9 @@ struct simulation
}
template
<
typename
Function
,
typename
...
Args
>
constexpr
auto
dispatch
_2
(
const
dynamics_type
type
,
Function
&&
f
,
Args
...
args
)
noexcept
constexpr
auto
dispatch
(
const
dynamics_type
type
,
Function
&&
f
,
Args
...
args
)
noexcept
{
switch
(
type
)
{
case
dynamics_type
::
none
:
...
...
@@ -5628,9 +5628,9 @@ struct simulation
}
template
<
typename
Function
,
typename
...
Args
>
constexpr
auto
dispatch
_2
(
const
dynamics_type
type
,
Function
&&
f
,
Args
...
args
)
const
noexcept
constexpr
auto
dispatch
(
const
dynamics_type
type
,
Function
&&
f
,
Args
...
args
)
const
noexcept
{
switch
(
type
)
{
case
dynamics_type
::
none
:
...
...
@@ -5744,7 +5744,7 @@ struct simulation
const
output_port_id
port
,
int
*
index
)
const
noexcept
{
return
dispatch
_2
(
return
dispatch
(
mdl
.
type
,
[
dyn_id
=
mdl
.
id
,
port
,
index
]
<
typename
DynamicsM
>
(
DynamicsM
&
dyn_models
)
->
status
{
...
...
@@ -5769,7 +5769,7 @@ struct simulation
template
<
typename
Function
>
void
for_all_input_port
(
const
model
&
mdl
,
Function
f
)
{
dispatch
_2
(
dispatch
(
mdl
.
type
,
[
this
,
&
f
,
dyn_id
=
mdl
.
id
]
<
typename
T
>
(
T
&
dyn_models
)
{
using
TT
=
T
;
using
Dynamics
=
typename
TT
::
value_type
;
...
...
@@ -5787,7 +5787,7 @@ struct simulation
template
<
typename
Function
>
void
for_all_output_port
(
const
model
&
mdl
,
Function
f
)
{
dispatch
_2
(
dispatch
(
mdl
.
type
,
[
this
,
&
f
,
dyn_id
=
mdl
.
id
]
<
typename
T
>
(
T
&
dyn_models
)
{
using
TT
=
T
;
using
Dynamics
=
typename
TT
::
value_type
;
...
...
@@ -5806,7 +5806,7 @@ struct simulation
const
input_port_id
port
,
int
*
index
)
const
noexcept
{
return
dispatch
_2
(
return
dispatch
(
mdl
.
type
,
[
dyn_id
=
mdl
.
id
,
port
,
index
]
<
typename
T
>
(
T
&
dyn_models
)
->
status
{
using
TT
=
T
;
...
...
@@ -5832,7 +5832,7 @@ struct simulation
int
index
,
output_port_id
*
port
)
const
noexcept
{
return
dispatch
_2
(
return
dispatch
(
mdl
.
type
,
[
dyn_id
=
mdl
.
id
,
index
,
port
]
<
typename
T
>
(
T
&
dyn_models
)
->
status
{
using
TT
=
T
;
...
...
@@ -5858,7 +5858,7 @@ struct simulation
int
index
,
input_port_id
*
port
)
const
noexcept
{
return
dispatch
_2
(
return
dispatch
(
mdl
.
type
,
[
dyn_id
=
mdl
.
id
,
index
,
port
]
<
typename
T
>
(
T
&
dyn_models
)
->
status
{
using
TT
=
T
;
...
...
@@ -6133,7 +6133,7 @@ public:
observers
.
free
(
*
obs
);
}
dispatch
_2
(
mdl
->
type
,
[
&
](
auto
&
d_array
)
{
dispatch
(
mdl
->
type
,
[
&
](
auto
&
d_array
)
{
do_deallocate
(
d_array
.
get
(
mdl
->
id
));
d_array
.
free
(
mdl
->
id
);
});
...
...
@@ -6421,7 +6421,7 @@ public:
status
make_initialize
(
model
&
mdl
,
time
t
)
noexcept
{
return
dispatch
_2
(
return
dispatch
(
mdl
.
type
,
[
this
,
&
mdl
,
t
]
<
typename
DynamicsModels
>
(
DynamicsModels
&
dyn_models
)
{
return
this
->
make_initialize
(
mdl
,
dyn_models
.
get
(
mdl
.
id
),
t
);
...
...
@@ -6492,12 +6492,12 @@ public:
time
t
,
flat_list
<
output_port_id
>&
o
)
noexcept
{
return
dispatch
_2
(
mdl
.
type
,
[
this
,
&
mdl
,
t
,
&
o
]
<
typename
DynamicsModels
>
(
DynamicsModels
&
dyn_models
)
{
return
this
->
make_transition
(
mdl
,
dyn_models
.
get
(
mdl
.
id
),
t
,
o
);
});
return
dispatch
(
mdl
.
type
,
[
this
,
&
mdl
,
t
,
&
o
]
<
typename
DynamicsModels
>
(
DynamicsModels
&
dyn_models
)
{
return
this
->
make_transition
(
mdl
,
dyn_models
.
get
(
mdl
.
id
),
t
,
o
);
});
}
};
...
...
lib/include/irritator/io.hpp
View file @
1805243f
...
...
@@ -693,7 +693,7 @@ private:
status
::
io_file_format_dynamics_unknown
);
model_id
mdl_id
=
static_cast
<
model_id
>
(
0
);
auto
ret
=
sim
.
dispatch
_2
(
type
,
[
this
,
&
sim
,
&
mdl_id
](
auto
&
dyn_models
)
{
auto
ret
=
sim
.
dispatch
(
type
,
[
this
,
&
sim
,
&
mdl_id
](
auto
&
dyn_models
)
{
irt_return_if_fail
(
dyn_models
.
can_alloc
(
1
),
status
::
io_file_format_dynamics_limit_reach
);
auto
&
dyn
=
dyn_models
.
alloc
();
...
...
@@ -1076,7 +1076,7 @@ struct writer
os
<<
id
<<
' '
;
map
[
id
]
=
mdl_id
;
sim
.
dispatch
_2
(
mdl
->
type
,
[
this
,
mdl
](
auto
&
dyn_models
)
{
sim
.
dispatch
(
mdl
->
type
,
[
this
,
mdl
](
auto
&
dyn_models
)
{
write
(
dyn_models
.
get
(
mdl
->
id
));
});
...
...
lib/test/public-api.cpp
View file @
1805243f
...
...
@@ -594,16 +594,16 @@ main()
auto
&
mdl
=
sim
.
models
.
get
(
dyn1
.
id
);
sim
.
dispatch
_2
(
mdl
.
type
,
[](
const
auto
&
dyns
)
{
std
::
cout
<<
"ok"
;
});
sim
.
dispatch
(
mdl
.
type
,
[](
const
auto
&
dyns
)
{
std
::
cout
<<
"ok"
;
});
auto
ret
=
sim
.
dispatch
_2
(
mdl
.
type
,
[](
const
auto
&
dyns
)
{
auto
ret
=
sim
.
dispatch
(
mdl
.
type
,
[](
const
auto
&
dyns
)
{
std
::
cout
<<
"ok"
;
return
1
;
});
expect
(
ret
==
1
);
auto
ret_2
=
sim
.
dispatch
_2
(
auto
ret_2
=
sim
.
dispatch
(
mdl
.
type
,
[](
const
auto
&
dyns
,
int
v1
,
double
v2
)
{
std
::
cout
<<
"ok"
<<
v1
<<
' '
<<
v2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment