1
/* *************************************************************************
2
* Copyright 2012 Jakob Gruber <jakob.gruber@gmail.com> *
4
* This program is free software: you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation, either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
16
************************************************************************* */
22
#include <QSharedPointer>
25
#include "boardstate.h"
27
/* Moved from streaks.cpp to work around QSharedPointer issues with forward declarations.
28
* TODO: move this back once when Qt 5 is used. */
30
LineInfo(const QVector<Board::State> &l);
34
QVector<int> streaks_regular;
35
QVector<int> streaks_reversed;
36
QVector<Board::State> line;
42
struct StreakElement {
47
Streaks(QSharedPointer<BoardMap> map, QSharedPointer<BoardState> state);
49
/* Updates streaks affected by changes to (x,y). */
50
void update(int x, int y);
52
/* Updates streaks, taking the entire board into account. */
55
/* Returns the request row/col streak. These contain the least information required by
56
the frontend, which is (for each position within a streak): "which number is this",
57
and "is this position solved" */
58
QVector<QSharedPointer<Streaks::StreakElement> > getRowStreak(int y) const;
59
QVector<QSharedPointer<Streaks::StreakElement> > getColStreak(int x) const;
63
void calcMapStreaks();
66
QSharedPointer<BoardMap> m_map;
67
QSharedPointer<BoardState> m_state;
69
QVector<QVector<int> > m_map_row_streaks;
70
QVector<QVector<int> > m_map_col_streaks;
72
QVector<QSharedPointer<LineInfo> > m_state_row_streaks;
73
QVector<QSharedPointer<LineInfo> > m_state_col_streaks;