/*
 * The UDS collection
 * Copyright (C) 1999, 2000, 2001  Julian v. Bock
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *	(See file COPYING for more information)
 */

#ifndef _uds_diagnose_hh
#define _uds_diagnose_hh


// includes

#include <string>

using namespace std;


namespace uds
{

/** Base class for diagnose classes which are used in exception classes.
	It gives more detailed error descriptions or an error diagnose.
	\author Julian v. Bock
	\see Exception */
class DiagBase
{
public:
	/** destructor */
	virtual
	~DiagBase();
	
	/** returns a diagnose string
		\return diagnose */
	virtual string
	Diagnose() const = 0;
	
	/** clones the class instance
		\return pointer to new class instance */
	virtual DiagBase*
	Clone() const = 0;
	
	/** \return true if the diagnose class provides an error code */
	virtual bool
	HaveErrCode() const { return false; }
	
	/** returns an error code if this is provided by the diagnose class.
		Otherwise an exception is thrown
		\return error code */
	virtual int
	ErrCode() const;
};


/** Diagnose class that doesn't give any diagnose ;-)
	\author Julian v. Bock */
class NoDiag : public DiagBase
{
public:
	/** destructor */
	virtual
	~NoDiag();
	
	/** returns a diagnose string
		\return diagnose */
	virtual string
	Diagnose() const { return string(); }
	
	/** clones the class instance
		\return pointer to new class instance */
	virtual NoDiag*
	Clone() const { return new NoDiag( *this ); }
};

}

#endif // _uds_diagnose_hh
