/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2006-2014  Georg Rudoy
 *
 * Boost Software License - Version 1.0 - August 17th, 2003
 *
 * Permission is hereby granted, free of charge, to any person or organization
 * obtaining a copy of the software and accompanying documentation covered by
 * this license (the "Software") to use, reproduce, display, distribute,
 * execute, and transmit the Software, and to prepare derivative works of the
 * Software, and to permit third-parties to whom the Software is furnished to
 * do so, all subject to the following:
 *
 * The copyright notices in the Software and this entire statement, including
 * the above license grant, this restriction and the following disclaimer,
 * must be included in all copies of the Software, in whole or in part, and
 * all derivative works of the Software, unless such copies or derivative
 * works are solely in the form of machine-executable object code generated by
 * a source language processor.
 *
 * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 **********************************************************************/

#ifndef INTERFACES_ENTITYTESTHANDLERESULT_H
#define INTERFACES_ENTITYTESTHANDLERESULT_H

/** @brief The result of testing whether an entity could be handled by a
 * plugin.
 *
 * Both processing an Entity with IEntityHandler and IDownload are
 * considered to be "handling".
 *
 * The test result also includes the so-called priority which shows how
 * much the plugin is ready to handle the entity. The higher is the
 * priority, the more ready the plugin is to handle the entity.
 *
 * Typically the handler with the highest priority will be chosen.
 * A value of 0 or lower means that the given entity can't be
 * handled by this handler/downloader at all.
 */
struct EntityTestHandleResult
{
	/** @brief The priority with which an entity could be handled.
	 */
	int HandlePriority_;

	/** @brief The typical values for the priority.
	 */
	enum Priority
	{
		PIdeal = 1000,
		PHigh = 800,
		PNormal = 600,
		PLow = 200,
		PNone = 0
	};

	/** @brief Whether other handlers should be canceled.
	 *
	 * If this is set to true, then other handlers won't be called to
	 * handle the given entity.
	 */
	bool CancelOthers_;

	/** @brief Default-constructs a test result.
	 *
	 * The default-constructed entity test handle result can't handle
	 * anything.
	 */
	EntityTestHandleResult ()
	: HandlePriority_ ()
	, CancelOthers_ (false)
	{
	}

	/** @brief Constructs a test result with given predefined priority.
	 *
	 * @param[in] prio One of the predefined priorities.
	 */
	explicit EntityTestHandleResult (Priority prio)
	: HandlePriority_ (prio)
	, CancelOthers_ (false)
	{
	}
};

#endif
