rlogiacco / CircularBuffer

Arduino circular buffer library
GNU Lesser General Public License v3.0
312 stars 85 forks source link

Supertype to allow pointers to CircularBuffers of different sizes #35

Closed sehrgut closed 4 years ago

sehrgut commented 4 years ago

In my application, I'm using CircularBuffer to implement a queue the size of which is determined by a child class, which enqueues items to be consumed by a parent-class method. It would be useful if CircularBuffer<T,S> implemented a parent class ICircularBuffer, allowing my parent class to hold a pointer to that type, while the size was managed by my child class (which knows S at compile-time).

Is this a feature you'd consider adding?

rlogiacco commented 4 years ago

I'm not sure why you can't achieve the same goal using composition rather than inheritance, anyways as the library strives for compactness I'm pretty sure the approach you suggest consumes a tiny bit more memory just to support a very specific requirement. If you get your changes working in your own fork and the community proves me wrong regarding my corner case statement we might have your changes integrated. For now, I prefer to keep the library as simple and compact as possible.

Nonetheless, I wish to thank you very much for the suggestion and for using this project.

Regards, Roberto