mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
devices: add index based device removal function
The undo machinery will need a method to remove devices based on their index instead of their name. Add it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
fa7dfa3710
commit
3a2f1b17b6
2 changed files with 8 additions and 0 deletions
|
@ -319,6 +319,13 @@ extern "C" int remove_device(struct device_table *device_table, const struct dev
|
|||
}
|
||||
}
|
||||
|
||||
extern "C" void remove_from_device_table(struct device_table *device_table, int idx)
|
||||
{
|
||||
if (idx < 0 || idx >= (int)device_table->devices.size())
|
||||
return;
|
||||
device_table->devices.erase(device_table->devices.begin() + idx);
|
||||
}
|
||||
|
||||
extern "C" void clear_device_table(struct device_table *device_table)
|
||||
{
|
||||
device_table->devices.clear();
|
||||
|
|
|
@ -32,6 +32,7 @@ extern const struct device *get_device_for_dc(const struct device_table *table,
|
|||
extern bool device_exists(const struct device_table *table, const struct device *dev);
|
||||
extern int add_to_device_table(struct device_table *table, const struct device *dev); // returns index
|
||||
extern int remove_device(struct device_table *table, const struct device *dev); // returns index or -1 if not found
|
||||
extern void remove_from_device_table(struct device_table *table, int idx);
|
||||
|
||||
// struct device accessors for C-code. The returned strings are not stable!
|
||||
const char *device_get_model(const struct device *dev);
|
||||
|
|
Loading…
Reference in a new issue