Skip to content

Add name remapping API #23

@pavel-kirienko

Description

@pavel-kirienko

The idea is roughly like this, borrowed from ROS, not yet finalized:

// Default behavior -- no remapping; assume the namespace is "my/own/ns"
cy_advertise_c(cy, &pub_a,  "foo", 0);  // resolves as "my/own/ns/foo"
cy_advertise_c(cy, &pub_b, "/foo", 0);  // resolves as "foo"

// Introduce remappings:
cy_remap(cy, "/my/own", "/");    // replace prefix "my/own" => "".
cy_remap(cy, "/foo",    "/zoo"); // replace prefix "foo" => "zoo".

// Alternative syntax for the above, same outcome:
cy_remap(cy, "my/own/*", "/");
cy_remap(cy, "foo/*",    "/zoo");

cy_advertise_c(cy, &pub_c,  "foo", 0);  // resolves as "ns/foo"
cy_advertise_c(cy, &pub_d, "/foo", 0);  // resolves as "zoo"

The implementation is absolutely straightforward and compact: we add a new WKV container that keeps the remappings suffixed with the * pattern; in the above case that would be my/own/* and foo/*. The first pattern to match defines the remapping: we take the prefix from the container and join it with the matched substitutions: ("my/own"=>"") / "ns" / "foo", etc.

The same way we could even do much more complex remappings like my/?/ns, although the need for that is not yet evident.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions