Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature req: add function chaining to all set...() functions -- return T& #356

Closed
diablodale opened this issue Jan 30, 2022 · 1 comment · Fixed by #373
Closed

feature req: add function chaining to all set...() functions -- return T& #356

diablodale opened this issue Jan 30, 2022 · 1 comment · Fixed by #373
Assignees

Comments

@diablodale
Copy link
Contributor

I request all set...() functions to support function chaining by returning a reference to themselves.
This is widely used across languages. Can be used both in C++ and in python bindings (python loves these).
Could combine with #355 as a task "make get() const and set() return T&"

myColorImgFrame.setCategory(2).setWidth(500).setHeight(200);
// or everything with rvalues
myfunc(myqueue->get<dai::ImgFrame>().setCategory(2).setWidth(500).setHeight(200));

Fixes are trivial

// old
void ImgFrame::setCategory(unsigned int category) {
    img.category = category;
}

// new
ImgFrame& ImgFrame::setCategory(unsigned int category) {
    img.category = category;
    return *this;
}

Setup

  • all

Repro

Found while writing my app and having to make temp variables just to set...() some things.

@themarpe themarpe self-assigned this Jan 31, 2022
@themarpe
Copy link
Collaborator

Thought about it as well, I think it will fit nicely.
Will address soon

@themarpe themarpe linked a pull request Feb 10, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants