Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

update k4a c++ functions to support function chaining #1514

Description

I request all possible k4a C++ functions be updated to support function chaining.
In general this means all possible functions do not return void. Instead, they return references to their own class.

For example

void set_timestamp(std::chrono::microseconds timestamp);  // old
k4a::image& set_timestamp(std::chrono::microseconds timestamp);  // new

void set_depth_image(const image &depth_image);  // old
k4a::capture& set_depth_image(const image &depth_image);  // new

// this enables function chaining...
k4a::capture capture;
k4a::image image;
image.set_timestamp(1234).set_exposure_time(7500);
capture.set_depth_image(image).set_color_image(image).set_temperature_c(30.2);

The sdk code changes are trivial. For example...

// existing SDK 1.4.1 code
void set_temperature_c(float temperature_c) noexcept
{
    k4a_capture_set_temperature_c(m_handle, temperature_c);
}

// new code
k4a::image& set_temperature_c(float temperature_c) noexcept
{
    k4a_capture_set_temperature_c(m_handle, temperature_c);
    return *this;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

EnhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions