C++ classes

Classes contained in C++ header files are usable from statecharts as well.

class Point
{
    public:
        int32_t get_x();
        void set_x(int32_t x);
        int32_t get_y();
        void set_y(int32_t y);
    private:
        int32_t x;
        int32_t y;
};

By importing a header file containing this C++ class definition, one or more variables of the Point type can be defined in the statechart:

import: "Point.h"
interface:
    var PointA: Point
    var PointB: Point
    out event e

As expected, it is possible to access public functions and fields of these variables. For example, x and y can be set and read from within a state’s or a transition’s reactions:

entry / PointA.set_x(42); PointA.set_y(0)
[PointA.get_x() == 42] / raise e