libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / apps / sudoku / SudokuField.h
blobace2647818484cf1167b60f48bae64a92a2fe3d8
1 /*
2 * Copyright 2007-2012, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef SUDOKU_FIELD_H
6 #define SUDOKU_FIELD_H
9 #include <Archivable.h>
10 #include <SupportDefs.h>
13 enum {
14 kInitialValue = 0x01,
18 class SudokuField : public BArchivable {
19 public:
20 SudokuField(uint32 size);
21 SudokuField(const BMessage* archive);
22 SudokuField(const SudokuField& other);
23 virtual ~SudokuField();
25 status_t InitCheck();
27 virtual status_t Archive(BMessage* archive, bool deep) const;
28 static SudokuField* Instantiate(BMessage* archive);
30 status_t SetTo(char base, const char* data);
31 void SetTo(const SudokuField* other);
32 void Reset();
34 bool IsSolved() const;
35 bool IsEmpty() const;
36 bool IsValueCompleted(uint32 value) const;
38 uint32 Size() const { return fSize; }
39 uint32 BlockSize() const { return fBlockSize; }
41 void SetHintMaskAt(uint32 x, uint32 y,
42 uint32 hintMask);
43 uint32 HintMaskAt(uint32 x, uint32 y) const;
44 bool HasHint(uint32 x, uint32 y, uint32 value) const;
46 void SetValidMaskAt(uint32 x, uint32 y,
47 uint32 validMask);
48 uint32 ValidMaskAt(uint32 x, uint32 y) const;
49 bool IsValid(uint32 x, uint32 y, uint32 value) const;
51 void SetFlagsAt(uint32 x, uint32 y, uint32 flags);
52 uint32 FlagsAt(uint32 x, uint32 y) const;
53 bool IsInitialValue(uint32 x, uint32 y) const;
55 void SetValueAt(uint32 x, uint32 y, uint32 value,
56 bool setSolved = false);
57 uint32 ValueAt(uint32 x, uint32 y) const;
59 void Dump();
61 private:
62 struct field {
63 field();
65 uint32 hint_mask;
66 uint32 valid_mask;
67 uint32 flags;
68 uint32 value;
71 bool _ValidValueAt(uint32 x, uint32 y) const;
72 void _ComputeValidMask(uint32 x, uint32 y,
73 bool setSolved);
74 void _UpdateValidMaskChanged(uint32 x, uint32 y,
75 bool setSolved);
76 const field& _FieldAt(uint32 x, uint32 y) const;
77 field& _FieldAt(uint32 x, uint32 y);
79 private:
80 uint32 fSize;
81 uint32 fBlockSize;
82 uint32 fMaxMask;
83 field* fFields;
87 #endif // SUDOKU_FIELD_H