I'm working on a (1) object that is needs to signal another (2) object that some data is ready for processing. But I need to distinguish if the (2) object needs to initialize how the data is processed for the first time. I had thought that I could pass a boolean value via pass-by-reference and then allow the slot to change it so when some more data is ready to be processed the slot wouldn't initialize it the second time around.
Example Code:
connect(this, SIGNAL(readySendData(bool &, MyData &)),
this, SLOT(sendData(bool &, MyData &)));
void DataProcessor::sendData(bool & intializationNeeded, MyData & data)
{
if(intializationNeeded)
{
// Do Initialization Stuff
intializationNeeded = false;
}
else
{
// Do Stuff
}
}
connect(this, SIGNAL(readySendData(bool &, MyData &)),
this, SLOT(sendData(bool &, MyData &)));
void DataProcessor::sendData(bool & intializationNeeded, MyData & data)
{
if(intializationNeeded)
{
// Do Initialization Stuff
intializationNeeded = false;
}
else
{
// Do Stuff
}
}
To copy to clipboard, switch view to plain text mode
Hopefully this is clear but I would like to check to see if initialization is needed. Then the slot will change the parameter from true to false. So then next time the signal readySendData is generated it will enter the else code block. Is this possible with Slots and Signals or does it violate the loose coupling scheme.
Bookmarks