Skip to content

Commit

Permalink
iox-eclipse-iceoryx#415 Fix links, add missing title and service defi…
Browse files Browse the repository at this point in the history
…nition

Signed-off-by: Marika Lehmann <marika.lehmann@apex.ai>
  • Loading branch information
FerdinandSpitzschnueffler committed Feb 21, 2022
1 parent 1075057 commit 2ae235e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ All new code should follow the folder structure.
### How to add a new example

1. Add the example in the ["List of all examples"](./iceoryx_examples/README.md)
2. Create a new file in `doc/website/getting-started/examples/foobar.md`. This file shall only set the title and include the readme from `./iceoryx_examples/foobar/README.md`
2. Create a new file in `doc/website/examples/foobar.md`. This file shall only set the title and include the readme from `./iceoryx_examples/foobar/README.md`
3. Add an `add_subdirectory` directive into `iceoryx_meta/CMakeLists.txt` in the `if(EXAMPLES)` section.
4. Consider using [geoffrey](https://github.com/elBoberido/geoffrey#geoffrey---syncs-source-code-to-markdown-code-blocks) for syncing code in code blocks with the respective source files
5. Add integration test for example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: ???
title: Searching for currently available services
---

{! ../iceoryx/iceoryx_examples/icediscovery/README.md !}
12 changes: 7 additions & 5 deletions iceoryx_examples/icediscovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
This example demonstrates how to search for specific services using the
iceoryx's `ServiceDiscovery`. It provides two applications - one offering
different services and one searching for these making different search queries.
A `service` in iceoryx is defined by a `ServiceDescription` that represents a
topic under which publisher/server and subscriber/client can exchange data.

<!--## Expected Output-->
<!-- @todo Add expected output with asciinema recording before v2.0-->
Expand All @@ -16,9 +18,9 @@ different services and one searching for these making different search queries.
We create several publishers which offer their services on construction by
default. For more dynamism the `cameraPublishers` offer/stop their services
periodically. If you want more information on how to create a publisher, have a
look at the [icehello](https://github.com/eclipse-iceoryx/iceoryx/tree/master/iceoryx_examples/icehello),
[icedelivery](https://github.com/eclipse-iceoryx/iceoryx/tree/master/iceoryx_examples/icedelivery),
and [iceoptions](https://github.com/eclipse-iceoryx/iceoryx/tree/master/iceoryx_examples/icedelivery)
look at the [icehello](https://github.com/eclipse-iceoryx/iceoryx/tree/v2.0.0/iceoryx_examples/icehello),
[icedelivery](https://github.com/eclipse-iceoryx/iceoryx/tree/v2.0.0/iceoryx_examples/icedelivery),
and [iceoptions](https://github.com/eclipse-iceoryx/iceoryx/tree/v2.0.0/iceoryx_examples/icedelivery)
examples.

### Find services
Expand All @@ -38,7 +40,7 @@ It is included via:
```

On that object we can call the method `findService` which expects the three
service [string identifiers](https://github.com/eclipse-iceoryx/iceoryx/blob/master/doc/website/getting-started/overview.md#creating-service-descriptions-for-topics)
service [string identifiers](https://github.com/eclipse-iceoryx/iceoryx/blob/v2.0.0/doc/website/getting-started/overview.md#creating-service-descriptions-for-topics)
and a callable which will be applied to all matching services. In this example
we pass a function that prints the found services on the console:

Expand Down Expand Up @@ -73,5 +75,5 @@ instance and any event. Since the `cameraPublishers` periodically offer/stop
their services, you should see sometimes 5 `Camera` services and sometimes none.
<center>
[Check out icediscovery on GitHub :fontawesome-brands-github:](https://github.com/eclipse-iceoryx/iceoryx/tree/master/iceoryx_examples/icediscovery){ .md-button }
[Check out icediscovery on GitHub :fontawesome-brands-github:](https://github.com/eclipse-iceoryx/iceoryx/tree/v2.0.0/iceoryx_examples/icediscovery){ .md-button }
</center>
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class ServiceDiscovery
/// @param[in] service service string to search for, a nullopt corresponds to a wildcard
/// @param[in] instance instance string to search for, a nullopt corresponds to a wildcard
/// @param[in] event event string to search for, a nullopt corresponds to a wildcard
/// @param[in] callable to apply to all matching services
/// @param[in] callableForEach callable to apply to all matching services
void findService(const cxx::optional<capro::IdString_t>& service,
const cxx::optional<capro::IdString_t>& instance,
const cxx::optional<capro::IdString_t>& event,
const cxx::function_ref<void(const capro::ServiceDescription&)>& callable) noexcept;
const cxx::function_ref<void(const capro::ServiceDescription&)>& callableForEach) noexcept;

friend iox::popo::NotificationAttorney;

Expand Down
15 changes: 9 additions & 6 deletions iceoryx_posh/source/runtime/service_discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ ServiceContainer ServiceDiscovery::findService(const cxx::optional<capro::IdStri
return searchResult;
}

void ServiceDiscovery::findService(const cxx::optional<capro::IdString_t>& service,
const cxx::optional<capro::IdString_t>& instance,
const cxx::optional<capro::IdString_t>& event,
const cxx::function_ref<void(const capro::ServiceDescription&)>& callable) noexcept
void ServiceDiscovery::findService(
const cxx::optional<capro::IdString_t>& service,
const cxx::optional<capro::IdString_t>& instance,
const cxx::optional<capro::IdString_t>& event,
const cxx::function_ref<void(const capro::ServiceDescription&)>& callableForEach) noexcept
{
if (!callable)
if (!callableForEach)
{
return;
}

auto lambda = [&](const roudi::ServiceRegistry::ServiceDescriptionEntry& s) { callable(s.serviceDescription); };
auto lambda = [&](const roudi::ServiceRegistry::ServiceDescriptionEntry& s) {
callableForEach(s.serviceDescription);
};

m_serviceRegistrySubscriber.take().and_then([&](popo::Sample<const roudi::ServiceRegistry>& serviceRegistrySample) {
m_serviceRegistry = *serviceRegistrySample;
Expand Down

0 comments on commit 2ae235e

Please sign in to comment.