Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
7645d35c
Commit
7645d35c
authored
3 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add overrides to Reader::subscribe(). Use a list of callbacks instead one per id
parent
c6ce2373
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!157
armem/dev => master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/libraries/armem/client/Reader.cpp
+14
-3
14 additions, 3 deletions
source/RobotAPI/libraries/armem/client/Reader.cpp
source/RobotAPI/libraries/armem/client/Reader.h
+16
-1
16 additions, 1 deletion
source/RobotAPI/libraries/armem/client/Reader.h
with
30 additions
and
4 deletions
source/RobotAPI/libraries/armem/client/Reader.cpp
+
14
−
3
View file @
7645d35c
...
...
@@ -86,7 +86,7 @@ namespace armarx::armem::client
void
Reader
::
updated
(
const
std
::
vector
<
MemoryID
>&
updatedSnapshotIDs
)
const
{
for
(
const
auto
&
[
subscription
,
callback
]
:
callbacks
)
for
(
const
auto
&
[
subscription
,
callback
s
]
:
this
->
callbacks
)
{
std
::
vector
<
MemoryID
>
matchingSnapshotIDs
;
...
...
@@ -100,7 +100,10 @@ namespace armarx::armem::client
if
(
not
matchingSnapshotIDs
.
empty
())
{
callback
(
subscription
,
matchingSnapshotIDs
);
for
(
auto
&
callback
:
callbacks
)
{
callback
(
subscription
,
matchingSnapshotIDs
);
}
}
}
}
...
...
@@ -124,7 +127,15 @@ namespace armarx::armem::client
void
Reader
::
subscribe
(
const
MemoryID
&
id
,
callback
callback
)
{
callbacks
[
id
]
=
callback
;
callbacks
[
id
].
push_back
(
callback
);
}
void
Reader
::
subscribe
(
const
MemoryID
&
subscriptionID
,
callback_updated_only
callback
)
{
subscribe
(
subscriptionID
,
[
callback
](
const
MemoryID
&
,
const
std
::
vector
<
MemoryID
>&
updatedSnapshotIDs
)
{
callback
(
updatedSnapshotIDs
);
});
}
...
...
This diff is collapsed.
Click to expand it.
source/RobotAPI/libraries/armem/client/Reader.h
+
16
−
1
View file @
7645d35c
...
...
@@ -27,8 +27,13 @@ namespace armarx::armem::client
{
using
callback
=
std
::
function
<
void
(
const
MemoryID
&
subscriptionID
,
const
std
::
vector
<
MemoryID
>&
updatedSnapshotIDs
)
>
;
using
callback_updated_only
=
std
::
function
<
void
(
const
std
::
vector
<
MemoryID
>&
updatedSnapshotIDs
)
>
;
template
<
class
CalleeT
>
using
member_callback
=
void
(
CalleeT
::*
)(
const
MemoryID
&
subscriptionID
,
const
std
::
vector
<
MemoryID
>&
updatedSnapshotIDs
);
template
<
class
CalleeT
>
using
member_callback_updated_only
=
void
(
CalleeT
::*
)(
const
std
::
vector
<
MemoryID
>&
updatedSnapshotIDs
);
public:
...
...
@@ -54,6 +59,7 @@ namespace armarx::armem::client
data
::
StoreResult
readAndStore
(
const
data
::
StoreInput
&
input
)
const
;
void
subscribe
(
const
MemoryID
&
subscriptionID
,
callback
callback
);
void
subscribe
(
const
MemoryID
&
subscriptionID
,
callback_updated_only
callback
);
/**
* Subscribe with a class member function:
* @code
...
...
@@ -69,6 +75,15 @@ namespace armarx::armem::client
};
subscribe
(
subscriptionID
,
cb
);
}
template
<
class
CalleeT
>
void
subscribe
(
const
MemoryID
&
subscriptionID
,
CalleeT
*
callee
,
member_callback_updated_only
<
CalleeT
>
callback
)
{
auto
cb
=
[
callee
,
callback
](
const
MemoryID
&
,
const
std
::
vector
<
MemoryID
>&
updatedSnapshotIDs
)
{
(
callee
->*
callback
)(
updatedSnapshotIDs
);
};
subscribe
(
subscriptionID
,
cb
);
}
/// Function handling updates from the MemoryListener ice topic.
void
updated
(
const
std
::
vector
<
MemoryID
>&
updatedIDs
)
const
;
...
...
@@ -84,7 +99,7 @@ namespace armarx::armem::client
private
:
std
::
unordered_map
<
MemoryID
,
callback
>
callbacks
;
std
::
unordered_map
<
MemoryID
,
std
::
vector
<
callback
>
>
callbacks
;
};
...
...
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