src/ai/api/ai_pathfinder.hpp
author truebrain
Wed, 26 Mar 2008 15:17:40 +0000
branchnoai
changeset 9823 0b7f816cf46f
parent 9681 3997f1ce203a
permissions -rw-r--r--
(svn r12431) [NoAI] -Add: added AIEventSubsidiaryOffer, which keeps you informed about new Subsidiaries
/* $Id$ */

/** @file ai_pathfinder.hpp Everything to query and build pathfinders */

#ifndef AI_PATHFINDER_HPP
#define AI_PATHFINDER_HPP

#include "ai_object.hpp"
#include "ai_tilelist.hpp"

/**
 * A class that handles the base pathfinder. It is ment as
 *  parent-class for real implementation so all PFs have a general
 *  interface, but can have different backends.
 */
class AIPathFinder : public AIObject {
public:
	/**
	 * The type of pathfinders known in the game.
	 */
	enum PathFinderType {
		PATHFINDER_ROAD,
		PATHFINDER_RAIL,
	};

	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AIPathFinder"; }

	/**
	 * Find a route between 2 points. Any pathfinder might have specific
	 *  functions to calibrate penalties and stuff.
	 * @param start a list of tiles from where we can start.
	 * @param end a list of tiles where we can end.
	 * @return internal structure about how to make the route, or NULL if no route was found.
	 */
	virtual void *FindRoute(AITileList *start, AITileList *end) = 0;

	/**
	 * Build the route as found by FindRoute.
	 * @param result the result 'void *' from FindRoute.
	 * @return true if the route was build, false if anything went wrong.
	 */
	virtual bool BuildRoute(void *result) = 0;

	/**
	 * When you are done with the route result, we have to free it in order to avoid memleaks.
	 * @note Always call this function on the result of FindRoute, even when you ran BuildRoute before!
	 */
	virtual void FreeRoute(void *result) = 0;

	/** Keep the compilers happy */
	virtual ~AIPathFinder() {}
};

#endif /* AI_PATHFINDER_HPP */