|
Boost Users : |
Subject: [Boost-users] [statechart] friend state can't call overloaded member functions in machine class
From: David Matz (david.matz_at_[hidden])
Date: 2009-07-14 07:34:56
Hi,
if one want to centralize all transition callbacks into the machine itself it's
a good way to declare the states as friends and call the machine member
functions which should (of course) private. But boost::statechart has problems
if the member functions in the machine class are overloaded. Then the friend
declaration is ignored by the compiler.
Here is a snippet to reproduce the error:
struct Active;
class CoreApp : public boost::statechart::state_machine< CoreApp, Active > {
friend struct Active;
public:
CoreApp() { initiate(); }
private:
void doInStateReaction(const EvNext &) {}
void doInStateReaction(const EvBack &) {} ///< uncomment this line to resolve
the error
};
struct Active : boost::statechart::simple_state< Active, CoreApp > {
typedef boost::mpl::list <
//sc::in_state_reaction < EvBack, CoreApp, &CoreApp::doInStateReaction >,
sc::in_state_reaction < EvNext, CoreApp, &CoreApp::doInStateReaction >
> reactions;
};
As one can see two functions doInStateReaction() are defined in the state
machine class. Comment the second one out and it compiles. This problem occurs
too if one uses a templated event which calls a templated function.
A easy solution to this problem is to rename the functions slightly but I hope
there is a better way. Has anyone an idea to catch this?
David
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net