FIFE  2008.0
searchspace.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_SEARCHSPACE
00023 #define FIFE_PATHFINDER_SEARCHSPACE
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 "model/structures/location.h"
00034 
00035 namespace FIFE {
00036 
00037     class Layer;
00038 
00039     class SearchSpace {
00040     public:
00041         SearchSpace(Layer* layer);
00042 
00043         int getUpperX() const {
00044             return m_upperX;
00045         }
00046 
00047         int getUpperY() const {
00048             return m_upperY;
00049         }
00050 
00051         int getLowerX() const {
00052             return m_lowerX;
00053         }
00054 
00055         int getLowerY() const {
00056             return m_lowerY;
00057         }
00058 
00059         int getWidth() const { 
00060             //1 is added to make it inclusive of the first cell.
00061             return (m_upperX - m_lowerX) + 1;
00062         }
00063 
00064         int getHeight() const {
00065             return (m_upperY - m_lowerY) + 1;
00066         }
00067 
00068         Layer* getLayer() const {
00069             return m_layer;
00070         }
00071 
00080         bool isInSearchSpace(const Location& location) const;
00081 
00090         ModelCoordinate translateCoordsToSearchSpace(const ModelCoordinate& coords) const;
00091 
00099         int convertCoordToInt(const ModelCoordinate& coord) const;
00100 
00109         ModelCoordinate convertIntToCoord(const int cell) const;
00110 
00115         int getMaxIndex() const;
00116     private:
00117         //The boundries of the search space.
00118         int m_upperX;
00119         int m_upperY;
00120         int m_lowerX;
00121         int m_lowerY;
00122 
00123         //The layer of the search space.
00124         Layer* m_layer;
00125     };
00126 
00127 }
00128 
00129 
00130 #endif