//--------------------------------------------------------------------------------------------
// <copyright file="LqrSMACException.h" company="LiquidRobotics">
//
// Copyright (c) 2014 Liquid Robotics, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// This software is associated with a release.  Liquid Robotics makes no
// representation that the design, interfaces or component distribution will
// remain unchanged in future releases.
//
// </copyright>
//
// <summary>
// Declares the LiquidRobotics::SMACFramework::Exception class, which is a base class for all
// exception classes.
// </summary>
//
// <owner>Mike Cookson</owner>
//--------------------------------------------------------------------------------------------

#ifndef __LqrSMACException_H__
#define __LqrSMACException_H__

#include "LqrSMACSharedLib.h"
#include <exception>
#include <string>

namespace LiquidRobotics {
namespace SMACFramework {

class SHARED_LIB_PUBLIC Exception : public std::exception
{
public:

	Exception(const char* p1) throw();
	Exception(const char* p1, const char* p2) throw();
	Exception(const char* p1, const char* p2, const char* p3) throw();
	Exception(const char* p1, const char* p2, const char* p3, const char* p4) throw();
	Exception(const char* p1, const char* p2, const char* p3, const char* p4, const char* p5) throw();
	Exception(const char* p1, const char* p2, const char* p3, const char* p4, const char* p5, const char* p6) throw();
	Exception(const Exception& other) throw();
	Exception& operator=(const Exception& other);
	const char* what() const throw();

private:

	void Add(const char* data) throw();

	char buffer[250];
};

class SHARED_LIB_PUBLIC AlreadyConnected : public Exception
{
public:

	AlreadyConnected() throw();
};

class SHARED_LIB_PUBLIC AlreadyInitialized : public Exception
{
public:

	AlreadyInitialized() throw();
};

class SHARED_LIB_PUBLIC InvalidArgument : public Exception
{
public:

	InvalidArgument(const char* parameterName, const char* message = NULL) throw();

private:

	static std::string MakeMessage(const char* parameterName, const char* message) throw();
};

class SHARED_LIB_PUBLIC NotConnected : public Exception
{
public:

	NotConnected() throw();
};

class SHARED_LIB_PUBLIC NotInitialized : public Exception
{
public:

	NotInitialized() throw();
};

class SHARED_LIB_PUBLIC NoSuchInstance : public Exception
{
public:

	NoSuchInstance(const char* name, const char* kind) throw();

private:

	static std::string MakeMessage(const char* name, const char* kind) throw();
};

class SHARED_LIB_PUBLIC InterfaceNotFound : public Exception
{
public:

	InterfaceNotFound(const char* message) throw();
	InterfaceNotFound(const char* instanceName, const char* typeName, const char* message = NULL) throw();
};

class SHARED_LIB_PUBLIC ItemNotFound : public Exception
{
public:

	ItemNotFound() throw();
	ItemNotFound(const char* message, const char* critera = NULL) throw();

private:

	static std::string MakeMessage(const char* message, const char* criteria) throw();
};

class SHARED_LIB_PUBLIC OrbNotInitialized : public Exception
{
public:

	OrbNotInitialized() throw();
};

class SHARED_LIB_PUBLIC OrbAlreadyInitialized : public Exception
{
public:

	OrbAlreadyInitialized() throw();
};

#if 0
class SystemException : public Exception
{
public:

	SystemException(const CORBA::SystemException& sysEx) throw();

private:

	std::string MakeReportString(const CORBA::SystemException& sysEx) throw();
};
#endif

class SHARED_LIB_PUBLIC WouldOverwrite : public Exception
{
public:

	WouldOverwrite() throw();
	WouldOverwrite(const char* message) throw();
};

}
}

#endif
