#ifndef _COMMON_VECTORHANDLER_HPP_
#define _COMMON_VECTORHANDLER_HPP_
#ifndef _COMMON_CALLBACK_HPP_
#include <common/callback.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif

class VectorHandler
{
public:
	enum CallOrder{FirstHandler,NormalHandler};
	enum HandlerType {NCCreateHandler,CreateHandler,InitDialogHandler,SizeHandler,PaintHandler,
	 EraseBackgroundHandler,CommandHandler,TimerHandler,CompactingHandler,WinIniChangeHandler,
	 SetFontHandler,SysColorChangeHandler,LeftButtonDoubleHandler,SetFocusHandler,KillFocusHandler,
	 KeyUpHandler,KeyDownHandler,SysKeyDownHandler,SysKeyUpHandler,MinMaxHandler,EnterIdleHandler,
	 MenuSelectHandler,DrawItemHandler,CloseHandler,CharHandler,LeftButtonDownHandler,LeftButtonUpHandler,
	 RightButtonDoubleHandler,RightButtonDownHandler,RightButtonUpHandler,NCLeftButtonDownHandler,
	 NCLeftButtonUpHandler,NCRightButtonDownHandler,NCRightButtonUpHandler,MouseMoveHandler,
	 ControlColorHandler,DDEInitiateHandler,DDEAckHandler,DDERequestHandler,DDETerminateHandler,
	 DDEDataHandler,MMOpenHandler,MMCloseHandler,MMDoneHandler,NCDestroyHandler,DestroyHandler,
	 NotifyHandler,DialogCodeHandler,MeasureItemHandler,HorizontalScrollHandler,VerticalScrollHandler,
	 DropFilesHandler,PaletteChangedHandler,MDIActivateHandler,MDIDestroyHandler,QueryEndSessionHandler,
	 UserHandler,ChangeCBChainHandler,DrawClipboardHandler,ActivateAppHandler,DisplayChangeHandler,
	 ShowWindowHandler,CaptureChangedHandler,DeviceChangeHandler};
	 VectorHandler(void);
	virtual ~VectorHandler();
	WORD insertHandler(HandlerType handlerType,PureCallback *lpCallback,CallOrder callOrder=NormalHandler);
	void removeHandler(HandlerType handlerType,PureCallback *lpCallback);
	CallbackData::ReturnType callHandlers(HandlerType handlerType,CallbackData someCallbackData);
protected:
	WORD isValidHandler(HandlerType handlerType,int vectorIndex)const;
	WORD installedHandlers(HandlerType handlerType)const;
private:
	CallbackData::ReturnType callHandler(Block<CallbackPointer> &someCallbackVector,CallbackData &someCallbackData);
	void removeHandler(Block<CallbackPointer> &someCallbackVector,CallbackPointer &locatePointer);
	WORD handlers(Block<CallbackPointer> &someCallbackVector)const;
	WORD insert(Block<CallbackPointer> &someHandlerBlock,PureCallback *lpCallback,CallOrder callOrder);

	Block<CallbackPointer> mNCCreateVector;
	Block<CallbackPointer> mCreateVector;
	Block<CallbackPointer> mInitDialogVector;
	Block<CallbackPointer> mSizeVector;
	Block<CallbackPointer> mPaintVector;
	Block<CallbackPointer> mCommandVector;
	Block<CallbackPointer> mCompactingVector;
	Block<CallbackPointer> mWinIniChangeVector;
	Block<CallbackPointer> mSysColorChangeVector;
	Block<CallbackPointer> mLeftButtonDoubleVector;
	Block<CallbackPointer> mLeftButtonDownVector;
	Block<CallbackPointer> mLeftButtonUpVector;
	Block<CallbackPointer> mNCLeftButtonDownVector;
	Block<CallbackPointer> mNCLeftButtonUpVector;
	Block<CallbackPointer> mNCRightButtonDownVector;
	Block<CallbackPointer> mNCRightButtonUpVector;
	Block<CallbackPointer> mRightButtonDoubleVector;
	Block<CallbackPointer> mRightButtonDownVector;
	Block<CallbackPointer> mRightButtonUpVector;
	Block<CallbackPointer> mTimerVector;
	Block<CallbackPointer> mSetFocusVector;
	Block<CallbackPointer> mKillFocusVector;
	Block<CallbackPointer> mKeyUpVector;
	Block<CallbackPointer> mKeyDownVector;
	Block<CallbackPointer> mSysKeyDownVector;
	Block<CallbackPointer> mSysKeyUpVector;
	Block<CallbackPointer> mMinMaxVector;
	Block<CallbackPointer> mEnterIdleVector;
	Block<CallbackPointer> mMenuSelectVector;
	Block<CallbackPointer> mDrawItemVector;
	Block<CallbackPointer> mCloseVector;
	Block<CallbackPointer> mCharVector;
	Block<CallbackPointer> mMouseMoveVector;
	Block<CallbackPointer> mNCDestroyVector;
	Block<CallbackPointer> mDestroyVector;
	Block<CallbackPointer> mControlColorVector;
	Block<CallbackPointer> mNotifyVector;
	Block<CallbackPointer> mDDEInitiateVector;
	Block<CallbackPointer> mDDEAckVector;
	Block<CallbackPointer> mDDERequestVector;
	Block<CallbackPointer> mDDETerminateVector;
	Block<CallbackPointer> mDDEDataVector;
	Block<CallbackPointer> mMMOpenVector;
	Block<CallbackPointer> mMMCloseVector;
	Block<CallbackPointer> mMMDoneVector;
	Block<CallbackPointer> mDialogCodeVector;
	Block<CallbackPointer> mSetFontVector;
  Block<CallbackPointer> mMeasureItemVector;
	Block<CallbackPointer> mVerticalScrollVector;
	Block<CallbackPointer> mHorizontalScrollVector;
	Block<CallbackPointer> mEraseBackgroundVector;
	Block<CallbackPointer> mDropFilesVector;
	Block<CallbackPointer> mPaletteChangedVector;
	Block<CallbackPointer> mMDIActivateVector;
	Block<CallbackPointer> mMDIDestroyVector;
	Block<CallbackPointer> mQueryEndSessionVector;
	Block<CallbackPointer> mUserVector;
	Block<CallbackPointer> mChangeCBChainVector;
	Block<CallbackPointer> mDrawClipboardVector;
	Block<CallbackPointer> mActivateAppVector;
	Block<CallbackPointer> mDisplayChangeVector;
	Block<CallbackPointer> mShowWindowVector;
	Block<CallbackPointer> mCaptureChangedVector;
	Block<CallbackPointer> mDeviceChangeVector;
};

inline
VectorHandler::VectorHandler(void)
{
}

inline
VectorHandler::~VectorHandler()
{
}

inline
WORD VectorHandler::handlers(Block<CallbackPointer> &someCallbackVector)const
{
	return (WORD)someCallbackVector.size();
}

inline
WORD VectorHandler::isValidHandler(HandlerType handlerType,int vectorIndex)const
{
	return (vectorIndex<installedHandlers(handlerType)?TRUE:FALSE);
}
#endif
