// WMStateMachine.h: interface for the WMStateMachine class.
//
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000 Robert Cunnings. All rights reserved.
//
// You may copy, modify, distribute or publish this code free of charge.
//
// NO WARRANTY: This software is provided AS IS, without warranty of any kind.
//
//////////////////////////////////////////////////////////////////////
//
// WMStateMachine class - a class for finite state machine implementation.
// 
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WMSTATEMACHINE_H__59245713_1BD2_11D3_9E20_00105AABC815__INCLUDED_)
#define AFX_WMSTATEMACHINE_H__59245713_1BD2_11D3_9E20_00105AABC815__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <map>
using namespace std;

class WMEventHandler;

typedef struct tagTransition
{
	int SourceState;
	int DestState;
	int Event;
	int TransIndex;
} TRANSITION, *LPTRANSITION;

class WMStateMachine  
{
public:
	WMStateMachine();
	virtual ~WMStateMachine();

	// implementation
	void Initialize(int nState, WMEventHandler *pHandler);
	void Transition(int nEvent);
	BOOL RegisterTransition(int nSourceState,
							int nDestState,
							int nEvent,
							int nTransIndex);

protected:

	typedef map<int, LPTRANSITION, less<int>, allocator<LPTRANSITION> > mapKeyToTransition;
	mapKeyToTransition m_TransitionMap;

	int m_nState;
	WMEventHandler *m_pHandler;
};

#endif // !defined(AFX_WMSTATEMACHINE_H__59245713_1BD2_11D3_9E20_00105AABC815__INCLUDED_)
