Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

C API: Expose Selection and setSelection functions

#1
The Python API has `robolink.Robolink.Selection` and `robolink.Robolink.setSelection` for interacting with the currently-selected items. Would it be possible to expose an analogous function in the C API?

`RoboDK_getItemList`is a good example of a similar function.


Code:
// example structure
void RoboDK_getSelection(struct RoboDK_t *inst, struct Item_t *itemlist, int32_t itemlist_maxsize, int32_t *itemlist_sizeout);
void RoboDK_setSelection(struct RoboDK_t *inst, struct Item_t *itemlist, int32_t itemlist_size);
#2
Hi sig.johnnson,
We have prepared a separate branch for checking the Selection() and setSelection() methods:
https://github.com/RoboDK/RoboDK-API/tre...on-methods
After your verification, we'll merge this branch into the main one.
Here's a description of the functions:
Code:
size_t RoboDK_Selection(struct RoboDK_t* inst, struct Item_t* items, size_t items_count);
void RoboDK_setSelection(struct RoboDK_t* inst, struct Item_t* items, size_t items_count);
RoboDK_Selection() always returns the number of items selected. The array of items will be filled if its pointer is not equal to zero and the number of items (items_count) is greater than zero. Of course, the array will not hold more than its size.
You can find out the number of selected items by calling:
Code:
size_t total_items = RoboDK_Selection(inst, NULL, 0);
#3
Hi Dmitry, I hope you enjoyed the recent holidays!

I was able to pull and test and it looks like things are working as-expected. Thank you for adding this so quickly.

Let me make one suggestion...

It looks like `RoboDK_getItemList` and `Robodk_getItemListFilter` are `void` functions, taking as argument a pointer to an `int32_t` where the number of filled items will be stored.
Code:
void RoboDK_getItemList(struct RoboDK_t *inst, struct Item_t *itemlist, int32_t itemlist_maxsize, int32_t *itemlist_sizeout);
void RoboDK_getItemListFilter(struct RoboDK_t *inst, const int32_t filter, struct Item_t *itemlist, int32_t itemlist_maxsize, int32_t *itemlist_sizeout);

`RoboDK_Selection` works similarly to the getItemList functions, but returns the number of filled items rather than taking a pointer to the number of filled items as an argument.
Code:
size_t RoboDK_Selection(struct RoboDK_t* inst, struct Item_t* items, size_t items_count);

In the interest of consistency, these three similar functions would ideally work the same: either all three would take a pointer or all three would return a value. It is more intuitive to me to return the number of filled items, like `RoboDK_Selection` does. However, I recognize that there are backwards-compatibility considerations that may make this challenging.
It would be suboptimal to have to implement the following...
Code:
size_t RoboDK_getItemList2(struct RoboDK_t *inst, struct Item_t *itemlist, int32_t itemlist_maxsize);
size_t RoboDK_getItemListFilter2(struct RoboDK_t *inst, const int32_t filter, struct Item_t *itemlist, int32_t itemlist_maxsize);
  




Users browsing this thread:
1 Guest(s)