Boost logo

Boost Users :

From: Tim Milward (tim.milward_at_[hidden])
Date: 2006-05-01 12:35:59


I've built a small test program with the statechart library. (See below)

It seems that the sequence of exit and entry actions invoked for a
transition are modeled according to the UML 1.5 specification. In other
words it models "external" transitions from the 2.0 spec. Is it
possible, or are there any plans to extend it, to model the more useful
local transitions from the 2.0 spec?

Tests with deep history produce a static assertion if you attempt to
transition to history of a containing state. UML 2.0 explicitly permits
this. Are there any plans to modify the library to permit this?

Yours,
Tim Milward

#include <iostream>

#include <boost/statechart/event.hpp>
#include <boost/statechart/state_machine.hpp>
#include <boost/statechart/simple_state.hpp>
#include <boost/statechart/transition.hpp>
#include <boost/statechart/deep_history.hpp>

using namespace std;
namespace sc = boost::statechart;

struct S0;
struct S00;

struct Machine : sc::state_machine< Machine, S0 >
{
        Machine() { cout << "Machine()\n"; }
        ~Machine() { cout << "~Machine()\n"; }
};

struct E0 : sc::event< E0 >
{
        E0() { cout << "E0()\n"; }
        ~E0() { cout << "~E0()\n"; }
};
struct E1 : sc::event< E1 >
{
        E1() { cout << "E1()\n"; }
        ~E1() { cout << "~E1()\n"; }
};

struct S0 : sc::simple_state< S0, Machine, S00, sc::has_deep_history >
{
        // this would comile fine
// typedef sc::transition<E0, sc::deep_history< S00 > > reactions; //
this invokes exit actions of S00 and S0 (an external transition)
        typedef sc::transition<E0, S00 > reactions;
        
        S0() { cout << "S0()\n"; }
        virtual ~S0() { cout << "~S0()\n"; }
};
struct S00 : sc::simple_state< S00, S0 >
{
        // this doesn't compile
// typedef sc::transition<E1, sc::deep_history< S00 > > reactions;
        // this invokes exit actions of S00 only
        typedef sc::transition<E1, S00 > reactions;
        
        S00() { cout << "S00()\n"; }
        virtual ~S00() { cout << "~S00()\n"; }
};

int main()
{
        Machine m;
        m.initiate();
        m.process_event(E0());
        m.process_event(E1());
        return 1;
}


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