이 문제를 해결하는 방법에 대한 아이디어가 있으십니까? 다음에 상태 차트/g ++ 4.3.2Boost.Statechart 버그에 대한 도움말
와트 우분투 8.10 1.39_0를 사용
는 문구 "버" 세 번 출력된다. 이벤트가 단지 하나의 "BUGGY"를 유발할 것이라고 기대할 수 있습니다. 내가 작업하고있는 프로젝트의 경우 여러 개의 상태에 도달하기 위해 이벤트가 필요하므로 discard_event()를 반환 할 수 없습니다. 일반적으로 직각 좌표 집합의 입니다. 상태 차트를 수정하는 대신 을 적용 할 수있는 해결 방법이 있으면 알려드립니다.
BUGGY이
BUGGY
편집이 ::
이것은 $ 고양이 bug.cpp
#include <boost/intrusive_ptr.hpp>
#include <boost/mpl/list.hpp> #include <boost/statechart/custom_reaction.hpp>
#include <boost/statechart/event.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/state.hpp>
#include <boost/statechart/state_machine.hpp>
#include <iostream>
using namespace std;
namespace sc = boost::statechart;
namespace mpl = boost::mpl;
struct evSay : sc::event<evSay>{ };
struct top;
struct c1;
struct c2;
struct c3;
struct sm : public sc::state_machine<sm,top> { };
struct top : sc::simple_state<top,sm,mpl::list<c1,c2,c3> > {
typedef sc::custom_reaction<evSay> reactions;
sc::result react(const evSay &) {
cout<<"BUGGY"<<endl;
return forward_event();
}
};
struct c1 : sc::simple_state <c1, top::orthogonal<0> > { };
struct c2 : sc::simple_state <c2, top::orthogonal<1> > { };
struct c3 : sc::state <c3, top::orthogonal<2> > {
c3(my_context ctx) : my_base(ctx) {
post_event(boost::intrusive_ptr<evSay> (
new evSay()));
}
};
int main() {
sm* fsm = new sm();
fsm->initiate();
delete fsm;
return 0;
}
$ g ++ bug.cpp & &
BUGGY ./a.out
#include <boost/intrusive_ptr.hpp>
#include <boost/mpl/list.hpp>
#include <boost/statechart/custom_reaction.hpp>
#include <boost/statechart/event.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/state.hpp>
#include <boost/statechart/state_machine.hpp>
#include <iostream>
using namespace std;
namespace sc = boost::statechart;
namespace mpl = boost::mpl;
namespace BUG {
struct evSay : sc::event<evSay>{ };
struct top;struct c1;struct c2;struct c3;struct c2_1;
struct sm : public sc::state_machine<sm,top> { };
struct top : sc::simple_state<top,sm,mpl::list<c1,c2,c3> > {
typedef sc::simple_state<top,sm,mpl::list<c1,c2,c3> > my_type;
typedef sc::custom_reaction<evSay> reactions;
sc::result react(const evSay &) {
cout<<"BUGGY"<<endl;
return forward_event();
}
};
struct c1 : sc::simple_state <c1, top::orthogonal<0> > { };
struct c2 : sc::simple_state <c2, top::orthogonal<1>, c2_1 > { };
struct c3 : sc::state <c3, top::orthogonal<2> > {
c3(my_context ctx) : my_base(ctx) {
post_event(boost::intrusive_ptr<evSay> (
new evSay()));
}
};
struct c2_1 : sc::simple_state<c2_1, c2 > {
typedef sc::custom_reaction<evSay> reactions;
sc::result react(const evSay &) {
cout<<"CHILD REACTION"<<endl;
return forward_event();
}
};
}
int main()
{
BUG::sm* fsm = new BUG::sm();
fsm->initiate();
delete fsm;
return 0;
}
출력 : BUGGY
아동 REACTION
BUGGY
BUGGY 경우 것 만 트리거 한 "버기"기대
나는 TOP이 evSay에 반응합니다. 나는 다른 주에서도 evSay에 반응하는 능력을 원한다. 그러나 나는 각 어린이가 진화에 대한 탑의 반응을 이어 받도록하고 싶지 않습니다. 내 코드가 c1, c2 또는 c3에서 evSay에 대한 반응이 없음을 알 수 있습니다. – KitsuneYMG
그래서 당신은 기본적으로 당신이 evSay를 전달한다고 말하고 있지만 정말로 전달하지는 않습니까? 당신은 버리거나 그 포워드가 다음 라인으로 실제로 전달 될 것임을 받아들입니다. – Pieter
편집을 참조하십시오. 이벤트 (evSay)를 반응하지 않는 상태 (c1, c2, c3)로 전달하면 부모의 반응이 발생해야하는 이유는 무엇이라고 생각하십니까? 응답을받지 못한 이벤트가 시스템을 백업하는 경우 BUGGY 인쇄를 4 번하지 않아야합니까? (상단에는 하나, 반응이없는 아이들은 각각 3 명씩) – KitsuneYMG