I'm working in an implementation of a circular buffer in an embedded system (microcontroller) using external memory chips for storing data logging. The circular buffer itself is not stored in internal ram, just the current node or data to be written.
I have different memory types: flash, magnetic... which work very different internally. To expand life span, flash will be written only when a full sector can be filled, but with others as soon as there is data.
What is the best design pattern to use to abstract the logic behind a circular buffer and the logic needed for each memory type?
My objective is to be able to be able to implement same circular buffer independent of the underlaying memory type and use the same interface. I've been thinking using an abstract class buffer and then derive a new object for each memory type using the virtual calls when writting. Maybe I'm missing other better patterns.
Aucun commentaire:
Enregistrer un commentaire