Wazman
18th December 2008, 23:01
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
}
}
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.
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
}
}
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.