Separating callback from other modules
Hello!
May I want something strange, but it interesting programming problem. So, I wrote class-wrapper Sensor that subscribes on topic (like /camera/image) and in callback receives data (like this->callback(Image& data), node.subscribe(..., &Sensor::callback). Data should be prepared by some filters. At this moment, filters called in callback:
void Sensor::callback(Image& data)
{
Image* newData;
newData = filter1(data);
newData = filter2(newData);
...
}
But I think it is not good. Is there way to separate them from Sensor? Something like this:
data = Sensor.getData();
data = filter1(data);
data = filter2(data);
I think that I missed simple idea of this.