#ifndef ATRSIOHANDLER_H
#define ATRSIOHANDLER_H

/*
   AtrSIOHandler.h - handles SIO commands, the image data is stored
   in an AtrImage object

   Copyright (C) 2002 Matthias Reichl <hias@horus.com>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/


#include "AbstractSIOHandler.h"
#include "AtrImage.h"
#include "SIOTracer.h"

class AtrSIOHandler : public AbstractSIOHandler {
public:
	AtrSIOHandler(AtrImage *image, bool takeOwnership = false);
	/*
	 * if takeOwnership is true, the SIO handler will free the
	 * image in the destructor!
	 */
	virtual ~AtrSIOHandler();
	virtual int ProcessCommandFrame(SIO_command_frame& frame, SIOWrapper* wrapper);

	virtual bool IsAtrSIOHandler() const;

	virtual void EnableHighSpeed(bool on);

	AtrImage* GetAtrImage();
	const AtrImage* GetConstAtrImage() const;

private:
	AtrImage* fImage;
	bool fImTheOwner;

	AtrImageConfig fImageConfig; // holds current image config
	AtrImageConfig fFormatConfig;
	/* fFormatConfig holds the format sent by the percom put command */
	/* At the moment this new config is only used after a "format disk" */
	/* command has been issued. In the time after the "percom put" */
	/* and before the "format disk" command, the (old) image config */
	/* is used. This behaviour is necessary, because some programs */
	/* send an invalid percom block to the drive. */

	bool fEnableHighSpeed;
	unsigned char fSpeedByte;

	SIOTracer* fTracer;
};

inline AtrImage* AtrSIOHandler::GetAtrImage()
{
	return fImage;
}

inline const AtrImage* AtrSIOHandler::GetConstAtrImage() const
{
	return fImage;
}

#endif
