eyalroz / cuda-api-wrappers

Thin, unified, C++-flavored wrappers for the CUDA APIs
BSD 3-Clause "New" or "Revised" License
786 stars 80 forks source link

Structure 'attributes' and 'properties' better, using container-like facades and proxies #574

Open eyalroz opened 9 months ago

eyalroz commented 9 months ago

Many of our the objects we wrap in the library have all sorts of "attributes" or "properties", with API functions for getting and setting them.

At the moment, we reflect this almost as-is, with set_whatever() and get_whatever() (or just ::whatever() if it's a method) for attributes named "whatever", or set(attribute_enum_t attribute, attribute_value_t value) and get(attribute_enum_t attribute).

This is overly-verbose and non-idiomatic. We should:

  1. Utilize proxies fort such attributes and properties, such that assigning to them triggers a set_ function and using their value triggers a get_.
  2. For the many-attribute case, have a map of these proxies, with each value being the proxy mentioned above; and an ability to access them using an expression such as: my_wrapped_object.attributes[whatever].