#ifndef SIOTRACER_H
#define SIOTRACER_H

/*
   SIOTracer - simple trace / debug printer module

   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 <stdio.h>
#include <sys/types.h>

#include "atarisio.h"

class SIOTracer {
public:

	SIOTracer();

	~SIOTracer();

	static SIOTracer* GetInstance();

	void SetTraceCommands(bool on);
	void SetTraceCommandResults(bool on);
	void SetTraceDataBlocks(bool on);

	void TraceCommandFrame(
		const SIO_command_frame &frame,
		const char *prefix = 0);

	void TraceCommandOK();
	void TraceCommandError(int returncode);

	void TraceDataBlock(
		int len,
		const unsigned char* block,
		const char *prefix = 0);

	void TraceDecodedPercomBlock(
		const unsigned char* block, /* 12 bytes long */
		const char *prefix = 0);
private:

	static SIOTracer* fInstance;

	bool fTraceCommands;
	bool fTraceCommandResults;
	bool fTraceDataBlocks;

	FILE * fFile;

};

inline SIOTracer* SIOTracer::GetInstance()
{
        if (fInstance == 0) {
                fInstance = new SIOTracer;
        }       
        return fInstance;
}

inline void SIOTracer::SetTraceCommands(bool on)
{
	fTraceCommands = on;
}

inline void SIOTracer::SetTraceCommandResults(bool on)
{
	fTraceCommandResults = on;
}

inline void SIOTracer::SetTraceDataBlocks(bool on)
{
	fTraceDataBlocks = on;
}

#endif
