
Originally Posted by
wysota
Something like that.
Ok. What do you think about the fact there is no function to obtain current state in QStateMachine's API although the state in which a state machine is, well it's the most important part of its state as an object?

Originally Posted by
wysota
I don't understand the problem

Maybe you should try to write some code and then we could work on it?
NetworkMachine * netMachine;
class UserMachine
{
public:
class UserTransition : public QAbstractTransition
{
//...
}
//...
}
bool UserMachine
::UserTransition::eventTest(QEvent * event
) {
if (event.type() == UserMachine::EventType::Query)
{
// we are forced to use switch here...
switch (currentState(netMachine))
{
case NetworkMachine::Connected:
case NetworkMachine::LoggedIn:
case NetworkMachine::Result:
return true;
default:
return false;
}
}
}
NetworkMachine * netMachine;
class UserMachine
{
public:
class UserTransition : public QAbstractTransition
{
//...
}
//...
}
bool UserMachine::UserTransition::eventTest(QEvent * event )
{
if (event.type() == UserMachine::EventType::Query)
{
// we are forced to use switch here...
switch (currentState(netMachine))
{
case NetworkMachine::Connected:
case NetworkMachine::LoggedIn:
case NetworkMachine::Result:
return true;
default:
return false;
}
}
}
To copy to clipboard, switch view to plain text mode
We need this switch statement above because we have to decide if we're doing transition or not based on the state of the network machine.
If we had more states in the user machine we wouldn't have to check the state of network machine. We would had enough number of states we wouldn't have need the network machine at all... What do you think?
Bookmarks