aikido icon indicating copy to clipboard operation
aikido copied to clipboard

Use strongly-typed enum flags.

Open brianhou opened this issue 7 years ago • 3 comments

#339 might not be ideal because the "options" can be arbitrary ints, rather than combinations of the options that we actually enumerate. If that's a problem, maybe something like this would be better?

This PR follows the blog post above. I think the biggest annoyance with this implementation is that there's no contextual conversion to bool, so you can't write something like if (mOptions & Options::POSITIONS). My intermediate workaround is to require Options::NONE = 0 and compare directly to that.

I'm not entirely convinced whether this complication is worth it. @jslee02, what do you think?


Before creating a pull request

  • [x] Document new methods and classes
  • [ ] Format code with make format

Before merging a pull request

  • [x] Set version target by selecting a milestone on the right side
  • [ ] Summarize this change in CHANGELOG.md
  • [x] Add unit test(s) for this change

brianhou avatar Feb 19 '18 23:02 brianhou

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@c08d6a4). Click here to learn what that means. The diff coverage is 72.72%.

@@            Coverage Diff            @@
##             master     #340   +/-   ##
=========================================
  Coverage          ?   77.62%           
=========================================
  Files             ?      261           
  Lines             ?     6592           
  Branches          ?        0           
=========================================
  Hits              ?     5117           
  Misses            ?     1475           
  Partials          ?        0
Impacted Files Coverage Δ
src/planner/WorldStateSaver.cpp 0% <0%> (ø)
src/statespace/dart/MetaSkeletonStateSaver.cpp 76% <100%> (ø)
include/aikido/common/EnumFlags.hpp 100% <100%> (ø)

codecov[bot] avatar Feb 20 '18 00:02 codecov[bot]

Just curious @brianhou @jslee02, can you implement something like the following to make that explicit boolean cast work?

(See Update section) https://stackoverflow.com/a/9883421

psigen avatar Oct 18 '18 00:10 psigen

Outdated, to consider for later

egordon avatar Nov 23 '22 06:11 egordon