Hi,
I am wondering what would be the best type of container class to use if I want to store the log of communication of an industrial bus. Each item is a structure, containing a date and time stamp, some kind of identifier and several bytes of data’s. Supposing there is up to 100 items to store per seconds and that it is very unlikely that I need to remove items from the container or to sort the container. I guess that my primary concern would be to find something that is very efficient in the amount of memory used to store my log.
So far QVector seems to be a good choice.
On the other side I am also looking into ways to limit the amount of data’s in the log – for example by implementing a ring buffer which a fixed size – let’s says several thousands of items – so that it can keep the log for the last minutes. With QVector I could only see it work by assigning a fixed size and by working with a firstItem and lastItem indicator. If I do not want to fix the size at the beginning would then QlinkedList or QList be a better choice? Waht would be the downside on the memory consumption ?
Also, as a last indication, I would like to be the list the source of data’s from a QAbstractItemModel class, so that I can attached some views and filtered views to it. I founf out that this may cause the things to be tricky too. For example the filter is usually computed when an item is added to the model; in case I am using a ring buffer, new items may replace older items; in such a case I need to evaluate the filter for the new item, but what's about the replaced item ?
If someone has some experience with such kind of things...
Bookmarks