gnuradio / pmt

pmt
GNU Lesser General Public License v3.0
11 stars 11 forks source link

Consider hiding implementations #7

Closed jsallay closed 2 years ago

jsallay commented 3 years ago

Right now each pmt type is divided into two pieces: a value class and a wrapper class. There is a note of the value class saying that it shouldn't be instantiated directly. It would be nice to make it so that it can't be instantiated at all. There are a few options for how to do this below.

  1. Use a pimpl. Rename the value class to be the impl class. The major difficulty here, is that the value classes are templates. If we wanted to write them in the compiled implementation file, then we need to instantiate every possible instance. This is possible, but it does limit the extensibility a little bit.
  2. Make the value class a private subclass of the wrapper. This should be pretty easy to do, because we wouldn't have to reorganize the code very much.
  3. Wait for c++20 support and use modules. This is a cop out answer, but it could work. If we control what is exported, then we don't have to export the value class.

As of right now, I would vote for option 2, but I am open to other opinions.

mormj commented 3 years ago

I agree with your assessment on 2 - seems like the most reasonable way to hide the implementation.

jsallay commented 2 years ago

No longer applicable because of https://github.com/gnuradio/pmt/pull/23