5
#include "constraint.h"
11
* \brief Graph represents the topology and the rules of a puzzle.
16
* \fn int Graph::valueCount() const
18
* Returns the maximum of different values.
22
* \fn int Graph::maxValue(int index) const
24
* Returns the maximum value for cell \a index.
25
* Currently same as valueCount()
29
* \fn int Graph::sizeX() const
31
* Returns the width of the game.
35
* \fn int Graph::sizeY() const
37
* Returns the height of the game.
41
* \fn int Graph::index(int x, int y) const
43
* Returns the index of the cell at (\a x, \a y).
47
* \fn int Graph::size() const
49
* Returns the count of cells in the gamefield.
53
* \fn int Graph::markerStart(int index) const
55
* Returns the position of cell \a index relative to the internal cache.
59
* \fn QVector<const ConstraintHelper*>& helpers() const
61
* Returns the list of helpers.
65
* \fn QVector<int> affectedHelpers(int node) const
67
* Returns the list of helpers that need to be (re)checked after
72
* Constructs a new graph with the width \a sizeX, height \a sizeY,
73
* and support for \a values different values at maximum.
79
* Destructs the graph.
82
QVector<Item*>::iterator it;
83
for(it = m_items.begin(); it != m_items.end(); ++it) {
91
void Ruleset::addHelper(ConstraintHelper* helper) {
92
int pos = m_helpers.size();
95
foreach(Item *item, helper->constraint()->affectedItems()) {
96
item->addAffectingHelper(helper);
102
* Adds \a item to the graph
104
* \a item is owned by graph and will be deleted at destruction.
106
void Ruleset::addItem(Item *item) {
107
item->setParent(this);
111
QVector<Storage*> Ruleset::storages() const {
115
Storage *Ruleset::storage(int id) {
116
return m_storages[id];
119
const Storage *Ruleset::storage(int id) const {
120
return m_storages[id];
123
int Ruleset::storageId(const QByteArray &name) const {
124
return m_storageIds.value(name, -1);
127
int Ruleset::regStorage(const QByteArray &name, Storage *storage) {
128
Q_ASSERT(!m_storageIds.contains(name));
129
Q_ASSERT(storage->storageId() < 0);
130
int id = m_storages.count();
131
m_storages << storage;
132
m_storageIds.insert(name, id);
133
storage->setStorageId(id);
137
#include "ruleset.moc"