#ifndef _H_BONDSM_SM
#define _H_BONDSM_SM

/*
 * ex: set ro:
 * DO NOT EDIT.
 * generated by smc (http://smc.sourceforge.net/)
 * from file : BondSM_sm.sm
 */


#define SMC_USES_IOSTREAMS

#include <smclib/statemap.h>

// Forward declarations.
class SM;
class SM_WaitingForSister;
class SM_Alive;
class SM_AwaitSisterDeath;
class SM_Dead;
class SM_Default;
class BondSMState;
class BondSMContext;
class BondSM;

class BondSMState :
    public statemap::State
{
public:

    BondSMState(const char *name, int stateId)
    : statemap::State(name, stateId)
    {};

    virtual void Entry(BondSMContext&) {};
    virtual void Exit(BondSMContext&) {};

    virtual void ConnectTimeout(BondSMContext& context);
    virtual void Die(BondSMContext& context);
    virtual void DisconnectTimeout(BondSMContext& context);
    virtual void HeartbeatTimeout(BondSMContext& context);
    virtual void SisterAlive(BondSMContext& context);
    virtual void SisterDead(BondSMContext& context);

protected:

    virtual void Default(BondSMContext& context);
};

class SM
{
public:

    static SM_WaitingForSister WaitingForSister;
    static SM_Alive Alive;
    static SM_AwaitSisterDeath AwaitSisterDeath;
    static SM_Dead Dead;
};

class SM_Default :
    public BondSMState
{
public:

    SM_Default(const char *name, int stateId)
    : BondSMState(name, stateId)
    {};

};

class SM_WaitingForSister :
    public SM_Default
{
public:
    SM_WaitingForSister(const char *name, int stateId)
    : SM_Default(name, stateId)
    {};

    void ConnectTimeout(BondSMContext& context);
    void Die(BondSMContext& context);
    void SisterAlive(BondSMContext& context);
    void SisterDead(BondSMContext& context);
};

class SM_Alive :
    public SM_Default
{
public:
    SM_Alive(const char *name, int stateId)
    : SM_Default(name, stateId)
    {};

    void Die(BondSMContext& context);
    void HeartbeatTimeout(BondSMContext& context);
    void SisterAlive(BondSMContext& context);
    void SisterDead(BondSMContext& context);
};

class SM_AwaitSisterDeath :
    public SM_Default
{
public:
    SM_AwaitSisterDeath(const char *name, int stateId)
    : SM_Default(name, stateId)
    {};

    void Die(BondSMContext& context);
    void DisconnectTimeout(BondSMContext& context);
    void HeartbeatTimeout(BondSMContext& context);
    void SisterAlive(BondSMContext& context);
    void SisterDead(BondSMContext& context);
};

class SM_Dead :
    public SM_Default
{
public:
    SM_Dead(const char *name, int stateId)
    : SM_Default(name, stateId)
    {};

    void ConnectTimeout(BondSMContext& context);
    void Die(BondSMContext& context);
    void DisconnectTimeout(BondSMContext& context);
    void HeartbeatTimeout(BondSMContext& context);
    void SisterAlive(BondSMContext& context);
    void SisterDead(BondSMContext& context);
};

class BondSMContext :
    public statemap::FSMContext
{
public:

    BondSMContext(BondSM& owner)
    : FSMContext(SM::WaitingForSister),
      _owner(owner)
    {};

    BondSMContext(BondSM& owner, const statemap::State& state)
    : FSMContext(state),
      _owner(owner)
    {};

    virtual void enterStartState()
    {
        getState().Entry(*this);
        return;
    }

    BondSM& getOwner() const
    {
        return (_owner);
    };

    BondSMState& getState() const
    {
        if (_state == NULL)
        {
            throw statemap::StateUndefinedException();
        }

        return (dynamic_cast<BondSMState&>(*_state));
    };

    void ConnectTimeout()
    {
        (getState()).ConnectTimeout(*this);
    };

    void Die()
    {
        (getState()).Die(*this);
    };

    void DisconnectTimeout()
    {
        (getState()).DisconnectTimeout(*this);
    };

    void HeartbeatTimeout()
    {
        (getState()).HeartbeatTimeout(*this);
    };

    void SisterAlive()
    {
        (getState()).SisterAlive(*this);
    };

    void SisterDead()
    {
        (getState()).SisterDead(*this);
    };

private:

    BondSM& _owner;
};


/*
 * Local variables:
 *  buffer-read-only: t
 * End:
 */

#endif // _H_BONDSM_SM
