Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gauthier Quesnel
irritator
Commits
5ec1ff96
Commit
5ec1ff96
authored
Apr 02, 2021
by
Gauthier Quesnel
Browse files
core: add dynamics_type to observer callback
parent
607ef3d2
Changes
8
Hide whitespace changes
Inline
Side-by-side
app/gui/node-editor.hpp
View file @
5ec1ff96
...
...
@@ -230,6 +230,7 @@ struct plot_output
{}
void
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
);
...
...
@@ -252,8 +253,9 @@ struct file_output
{}
void
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
);
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
);
editor
*
ed
=
nullptr
;
std
::
ofstream
ofs
;
...
...
app/gui/simulation-editor.cpp
View file @
5ec1ff96
...
...
@@ -29,6 +29,7 @@ namespace irt {
void
plot_output
::
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
)
{
...
...
@@ -63,6 +64,7 @@ plot_output::operator()(const irt::observer& obs,
void
file_output
::
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
)
{
...
...
lib/benchmark/benchmark_exactitude_aqss.cpp
View file @
5ec1ff96
...
...
@@ -34,6 +34,7 @@ struct file_output
}
void
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
)
noexcept
{
...
...
lib/benchmark/benchmark_exactitude_qss1.cpp
View file @
5ec1ff96
...
...
@@ -34,6 +34,7 @@ struct file_output
}
void
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
)
{
...
...
lib/benchmark/benchmark_exactitude_qss2.cpp
View file @
5ec1ff96
...
...
@@ -34,6 +34,7 @@ struct file_output
}
void
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
)
{
...
...
lib/include/irritator/core.hpp
View file @
5ec1ff96
...
...
@@ -2477,7 +2477,8 @@ struct observer
};
using
update_fn
=
function_ref
<
void
(
const
observer
&
,
const
time
,
const
observer
::
status
)
>
;
function_ref
<
void
(
const
observer
&
,
const
dynamics_type
,
const
time
,
const
observer
::
status
)
>
;
observer
(
const
char
*
name_
,
update_fn
cb_
)
noexcept
:
cb
(
cb_
)
...
...
@@ -6475,9 +6476,11 @@ public:
irt
::
observer
*
obs
=
nullptr
;
while
(
observers
.
next
(
obs
))
{
obs
->
tl
=
t
;
if
(
!
obs
->
cb
.
empty
())
obs
->
cb
(
*
obs
,
t
,
observer
::
status
::
initialize
);
if
(
auto
*
mdl
=
models
.
try_to_get
(
obs
->
model
);
mdl
)
{
obs
->
msg
.
reset
();
obs
->
cb
(
*
obs
,
mdl
->
type
,
t
,
observer
::
status
::
initialize
);
obs
->
tl
=
t
;
}
}
return
status
::
success
;
...
...
@@ -6585,7 +6588,7 @@ public:
if
(
mdl
.
obs_id
!=
static_cast
<
observer_id
>
(
0
))
{
if
(
auto
*
obs
=
observers
.
try_to_get
(
mdl
.
obs_id
);
obs
)
{
obs
->
msg
=
dyn
.
observation
(
t
-
mdl
.
tl
);
obs
->
cb
(
*
obs
,
t
,
observer
::
status
::
run
);
obs
->
cb
(
*
obs
,
mdl
.
type
,
t
,
observer
::
status
::
run
);
obs
->
tl
=
t
;
}
else
{
mdl
.
obs_id
=
static_cast
<
observer_id
>
(
0
);
...
...
@@ -6625,7 +6628,7 @@ public:
{
if
constexpr
(
is_detected_v
<
observation_function_t
,
Dynamics
>
)
{
obs
.
msg
=
dyn
.
observation
(
t
-
mdl
.
tl
);
obs
.
cb
(
obs
,
t
,
observer
::
status
::
finalize
);
obs
.
cb
(
obs
,
mdl
.
type
,
t
,
observer
::
status
::
finalize
);
obs
.
tl
=
t
;
}
}
...
...
@@ -6645,8 +6648,7 @@ public:
model
*
mdl
=
nullptr
;
while
(
models
.
next
(
mdl
))
{
if
(
mdl
->
obs_id
!=
static_cast
<
observer_id
>
(
0
))
{
if
(
auto
*
obs
=
observers
.
try_to_get
(
mdl
->
obs_id
);
obs
&&
!
obs
->
cb
.
empty
())
{
if
(
auto
*
obs
=
observers
.
try_to_get
(
mdl
->
obs_id
);
obs
)
{
dispatch
(
mdl
->
type
,
[
this
,
mdl
,
obs
,
t
]
<
typename
DynamicsModels
>
(
DynamicsModels
&
dyn_models
)
{
...
...
lib/test/auditory.cpp
View file @
5ec1ff96
...
...
@@ -24,6 +24,7 @@ struct file_output
{}
void
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
)
{
...
...
lib/test/public-api.cpp
View file @
5ec1ff96
...
...
@@ -33,6 +33,7 @@ struct file_output
}
void
operator
()(
const
irt
::
observer
&
obs
,
const
irt
::
dynamics_type
/*type*/
,
const
irt
::
time
t
,
const
irt
::
observer
::
status
s
)
noexcept
{
...
...
@@ -46,6 +47,7 @@ struct file_output
break
;
case
irt
::
observer
::
status
::
finalize
:
fmt
::
print
(
os
,
"{},{}
\n
"
,
t
,
obs
.
msg
.
real
[
0
]);
break
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment