FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator
routepathersearch.h
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2008 by the FIFE team                              *
00003  *   http://www.fifengine.de                                               *
00004  *   This file is part of FIFE.                                            *
00005  *                                                                         *
00006  *   FIFE is free software; you can redistribute it and/or                 *
00007  *   modify it under the terms of the GNU Lesser General Public            *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2.1 of the License, or (at your option) any later version.    *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020  ***************************************************************************/
00021 
00022 #ifndef FIFE_PATHFINDER_ROUTEPATHERSEARCH
00023 #define FIFE_PATHFINDER_ROUTEPATHERSEARCH
00024 
00025 // Standard C++ library includes
00026 
00027 // 3rd party library includes
00028 
00029 // FIFE includes
00030 // These includes are split up in two parts, separated by one empty line
00031 // First block: files included from the FIFE root src directory
00032 // Second block: files included from the same folder
00033 #include "util/structures/priorityqueue.h"
00034 
00035 namespace FIFE {
00036 
00037     class Map;
00038     class SearchSpace;
00039     class Heuristic;
00040 
00045     class RoutePatherSearch {
00046     public:
00047         RoutePatherSearch(const int session_id, const Location& from, const Location& to, SearchSpace* searchSpace);
00048 
00049                 typedef std::list<Location> Path;
00053                 enum SearchStatus {
00054                         search_status_failed,
00055                         search_status_complete,
00056                         search_status_incomplete
00057                 };
00058 
00059         virtual void updateSearch();
00060 
00061         virtual Path calcPath();
00062 
00067                 int getSessionId() const {
00068                         return m_sessionId;
00069                 }
00070 
00075                 SearchSpace* getSearchSpace() const {
00076                         return m_searchspace;
00077                 }
00078 
00083                 int getSearchStatus() const {
00084                         return m_status;
00085                 }
00086 
00087          protected:
00092                 void setSearchStatus(const SearchStatus status) {
00093                         m_status = status;
00094                 }
00095 
00096          private:
00097                 //A location object representing where the search started.
00098                 Location                m_to;
00099 
00100                 //A location object representing where the search ended.
00101                 Location                m_from;
00102 
00103                 //An integer containing the session id for this search.
00104                 int                             m_sessionId;
00105 
00106                 //A pointer to the pather that owns this search.
00107                 SearchSpace*    m_searchspace;
00108 
00109                 //An enumeration of the searches current status.
00110                 SearchStatus    m_status;
00111                 
00112                 //The start coordinate as an int.
00113                 int             m_startCoordInt;
00114                 
00115                 //The destination coordinate as an int.
00116                 int             m_destCoordInt;
00117                 
00118                 //The next coordinate to check out.
00119                 int             m_next;
00120 
00121                 //The class to use to calculate the heuristic value.
00122                 Heuristic*                m_heuristic;
00123 
00124         //The shortest path tree.
00125         std::vector<int>          m_spt;
00126 
00127         //The search frontier.
00128         std::vector<int>          m_sf;
00129 
00130         //A table to hold the costs.
00131         std::vector<float>        m_gCosts;
00132 
00133         //priority queue to hold nodes on the sf in order. 
00134         PriorityQueue<int, float> m_sortedfrontier;
00135     };
00136 }
00137 #endif