File: cell.h

package info (click to toggle)
kapman 4:20.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 3,588 kB
  • sloc: cpp: 2,793; xml: 208; makefile: 8; sh: 2
file content (119 lines) | stat: -rw-r--r-- 2,813 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CELL_H
#define CELL_H

#include <QtGlobal>

class Element;

/**
 * @brief This class represents a Cell of the Maze.
 */
class Cell
{

public:

    /** The Cell side size */
    static const qreal SIZE;

    /** The Cell possible types */
    enum Type {
        WALL = 0,
        CORRIDOR = 1,
        GHOSTCAMP = 2
    };

private:

    /** The Cell type */
    Type m_type;

    /** A reference on the Element that is on the Cell */
    Element *m_element;

    /** Cost used in A* pathfinding algorithm : lower is the cost, closer to the target Cell is this Cell */
    int m_cost;

    /** Parent node used in A* pathfinding algorithm : the Cell which enables to go to this Cell */
    Cell *m_parent;

public:

    /**
     * Creates a new Cell instance.
     */
    Cell();

    /**
     * Deletes the Cell instance.
     */
    ~Cell();

    /**
     * Gets the Cell type.
     * @return the Cell type
     */
    Type getType() const;

    /**
     * Sets the Cell type.
     * @param p_type the new type to set
     */
    void setType(Type p_type);

    /**
     * Gets the Element that is on the Cell.
     * @return the Element that is on the Cell
     */
    Element *getElement() const;

    /**
     * Sets the Element that is on the Cell.
     * @param p_element the Element to set on the Cell
     */
    void setElement(Element *p_element);

    /**
     * Gets the Cell cost for A* pathfinding algorithm.
     * @return the Cell cost for A* pathfinding algorithm
     */
    int getCost() const;

    /**
     * Sets a cost for the Cell, for A* pathfinding algorithm.
     * @param p_cost the cost of the Cell for A* pathfinding algorithm
     */
    void setCost(const int p_cost);

    /**
     * Gets the parent Cell of this Cell for A* pathfinding algorithm.
     * @return the Cell parent for A* pathfinding algorithm
     */
    Cell *getParent() const;

    /**
     * Sets the parent Cell of this Cell for A* pathfinding algorithm.
     * @param p_parent the parent of the Cell for A* pathfinding algorithm
     */
    void setParent(Cell *p_parent);
};

#endif