Given a simple class that has a private member for instance a
double *data_series
This member is allocated and filled with data from a qt slot like so:
int channel_count = ...
data = new double[channel_count];
std::copy(input_data, input_data+channel_count, data);
in the dtor of this class the data ptr is deleted.
Now, this simple class holds small samples of data that are retrieved and each of theses classes/frames are emitted and should then be handled by all the connected slots in a good way, note that the data pointed by the data ptr is never modified, just read.
I am not too good at smart pointers so first I had the case with only one slot connected so not a big issue, I could just emit pointer to the class and delete the class in the slot when done. The problem arises when multiple slots are connected, the data pointer should only be deleted when all slots are done with the data. I can not emit the class by value since I dont want to have a copy ctor that duplicates the data all the time.
So, should I emit some kind of smart pointer to the class? Or should I manage the data pointer using a smart pointer somehow. I am looking for a good pattern here for me to follow.
brgds