First, very, very, very simplified version of a C++ version of the component system. Experience of using a similar simplified system to teach a pre-university trainee how to use Axon suggest that this minimal subset (if we choose to extend slightly) is actually very useful.
First, very, very, very simplified version of a C++ version of the
component system. Experience of using a similar simplified system to
teach a pre-university trainee how to use Axon suggest that this minimal
subset (if we choose to extend slightly) is actually very useful.

Example system:
-------------------------------------------------------------
struct Producer : public VerySimpleComponent {
    virtual int next() {
    GENERATOR_CODE_START
        while(1) {
           send("hello world");
           YIELD(1);
        };
    GENERATOR_CODE_END
    };
};

struct Consumer : public VerySimpleComponent {
    string result;
    virtual int next() {
    GENERATOR_CODE_START
        while (1) {
            if (dataReady()) {
               result = recv();
               cout << "! " << result << endl;
            };
            YIELD(1);
        };
    GENERATOR_CODE_END
    };
};

Producer P;
Consumer C;
Postman postie(&P,&C);
scheduler.activateMicroprocess(&P);
scheduler.activateMicroprocess(&C);
scheduler.activateMicroprocess(&postie);
runScheduler(&scheduler);
-------------------------------------------------------------

Clearly in the above the two components are running in parallel, much like
state machines, but are much clearer than state machines in their logic.


Michael.

sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia