Thread (10 messages) 10 messages, 3 authors, 2021-07-22

Re: [libgpiod][PATCH v2 3/3] bindings: cxx: implement C++ bindings for libgpiod v2.0

From: Bartosz Golaszewski <hidden>
Date: 2021-07-16 08:56:43

On Fri, Jul 16, 2021 at 9:44 AM Bartosz Golaszewski [off-list ref] wrote:
On Fri, Jul 16, 2021 at 12:18 AM Ben Hutchings
[off-list ref] wrote:
quoted
On Thu, Jul 15, 2021 at 10:10:01PM +0200, Bartosz Golaszewski wrote:
quoted
This is the bulk of work implementing C++ bindings for the new libgpiod
API. The tests are not converted yet but the examples are fully
functional. More details in the cover letter as this patch will be
squashed with the one for the core C library anyway.
[...]
quoted
+class line_config
+{
+public:
+
+     /**
+      * @brief Direction settings.
+      */
+     enum : int {
+             DIRECTION_AS_IS = 1,
+             /**< Request the line(s), but don't change current direction. */
+             DIRECTION_INPUT,
+             /**< Request the line(s) for reading the GPIO line state. */
+             DIRECTION_OUTPUT
+             /**< Request the line(s) for setting the GPIO line state. */
+     };
[...]
quoted
+class line_info
+{
+public:
+
+     /**
+      * @brief Direction settings.
+      */
+     enum : int {
+             DIRECTION_INPUT = 1,
+             /**< Direction is input - we're reading the state of a GPIO line. */
+             DIRECTION_OUTPUT
+             /**< Direction is output - we're driving the GPIO line. */
+     };
[...]

Could these be enum class types, or does that introduce an ABI issue
if you extend them later?

Ben.
I'm not sure there would be any benefit to enum classes here except
for longer scope when using them in code. I would prefer to leave it
this way.

Bartosz
Actually after a second thought, it wouldn't make it long - it would
just look like: line_info::direction::INPUT instead. Maybe it is a
more C++ approach after all.

Bart
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help