diff options
author | Thomas Günther <tom@toms-cafe.de> | 2007-09-22 01:01:10 +0200 |
---|---|---|
committer | Thomas Günther <tom@toms-cafe.de> | 2007-09-22 01:01:10 +0200 |
commit | 135a8c9447ca19c4d609373b228bd096a2ae2ab8 (patch) | |
tree | 1f24e7f3d0d4531d1a5bd705b89c40e7c3c29d33 /heap.h | |
parent | b39a6bf3e7add336dbb127394e8c611ec1d29cd6 (diff) | |
download | vdr-plugin-spider-135a8c9447ca19c4d609373b228bd096a2ae2ab8.tar.gz vdr-plugin-spider-135a8c9447ca19c4d609373b228bd096a2ae2ab8.tar.bz2 |
Added namespaces
Diffstat (limited to 'heap.h')
-rw-r--r-- | heap.h | 212 |
1 files changed, 109 insertions, 103 deletions
@@ -17,162 +17,168 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * $Id: heap.h 87 2007-06-22 22:37:36Z tom $ + * $Id: heap.h 95 2007-09-21 23:01:10Z tom $ */ #ifndef VDR_SPIDER_HEAP_H #define VDR_SPIDER_HEAP_H #include "spider.h" -class Card; -typedef Vector<Card> CardStack; -class Deck; -class Pile; -typedef Array<Pile*> Piles; -/** --- base class Heap ---------------------------------------------------- **/ - -class Heap +namespace Spider { -protected: - CardStack allCards; - unsigned int maxCount; - bool emptyChanged; + class Card; + typedef Vector<Card> CardStack; + class Deck; + class Pile; + typedef Array<Pile*> Piles; - /** Constructor */ - Heap(unsigned int maxCards); - /** Destructor */ - virtual ~Heap(); + //--- virtual base class Spider::Heap ---------------------------------------- -public: + class Heap + { + protected: + CardStack allCards; + unsigned int maxCount; + bool emptyChanged; - /** Current count of cards */ - int count() const; + /** Constructor */ + Heap(unsigned int maxCards); - /** Card in heap */ - const Card& card(int position) const; + /** Destructor */ + virtual ~Heap(); - /** Top card of the heap */ - const Card& top() const; + public: - /** Add a new card */ - virtual void add(const Card& card); + /** Current count of cards */ + int count() const; - /** Remove the top card */ - virtual void remove(); + /** Card in heap */ + const Card& card(int position) const; - /** Move some matching cards to an other heap */ - void moveTo(Heap* other, int countToMove); + /** Top card of the heap */ + const Card& top() const; - /** Is the heap empty? */ - bool empty() const; + /** Add a new card */ + virtual void add(const Card& card); - /** Is the heap changed? */ - bool changed() const; + /** Remove the top card */ + virtual void remove(); - /** Reset changed property */ - void resetChanged(); -}; + /** Move some matching cards to an other heap */ + void moveTo(Heap* other, int countToMove); + /** Is the heap empty? */ + bool empty() const; -/** --- class Pack --------------------------------------------------------- **/ + /** Is the heap changed? */ + bool changed() const; -class Pack : public Heap -{ -public: + /** Reset changed property */ + void resetChanged(); + }; - /** Constructor */ - Pack(const Deck& deck); - /** First initial deal of a game */ - void initialDeal(Piles& piles, int rows, Piles& extra); + //--- class Spider::Pack ----------------------------------------------------- - /** Deal one row to the piles */ - void deal(Piles& piles); + class Pack : public Heap + { + public: - /** Cancel the deal */ - void takeBackDeal(Piles& piles); -}; + /** Constructor */ + Pack(const Deck& deck); + /** First initial deal of a game */ + void initialDeal(Piles& piles, int rows, Piles& extra); -/** --- class Pile --------------------------------------------------------- **/ + /** Deal one row to the piles */ + void deal(Piles& piles); -class Pile : public Heap -{ -protected: - int currentOpen; - int currentMatching; - int currentSelected; - int currentChanged; + /** Cancel the deal */ + void takeBackDeal(Piles& piles); + }; -public: - /** Constructor */ - Pile(const Deck& deck); + //--- class Spider::Pile ----------------------------------------------------- - /** Add a new card */ - void add(const Card& card); + class Pile : public Heap + { + protected: + int currentOpen; + int currentMatching; + int currentSelected; + int currentChanged; - /** Remove top card from pile */ - void remove(); + public: - /** Turn all open top cards or rather open the top card */ - void turn(); + /** Constructor */ + Pile(const Deck& deck); - /** Current count of open cards */ - int open() const; + /** Add a new card */ + void add(const Card& card); - /** Current count of matching cards */ - int getMatching() const; + /** Remove top card from pile */ + void remove(); - /** The two open top cards are matching */ - bool topCardsMatches() const; + /** Turn all open top cards or rather open the top card */ + void turn(); - /** Current count of selected cards */ - int selected() const; + /** Current count of open cards */ + int open() const; - /** Select up to max matching cards on the end of this pile */ - void select(int max = 0); + /** Current count of matching cards */ + int getMatching() const; - /** Unselect this pile */ - void unselect(); + /** The two open top cards are matching */ + bool topCardsMatches() const; - /** Adapt the selection to match an other pile */ - void adaptSelectionTo(const Pile* other); + /** Current count of selected cards */ + int selected() const; - /** Matches the selection to an other pile? */ - bool selectionMatchesTo(const Pile* other, bool matchSuit = false) const; + /** Select up to max matching cards on the end of this pile */ + void select(int max = 0); - /** Is the heap changed? */ - bool changed() const; + /** Unselect this pile */ + void unselect(); - /** Reset changed property */ - void resetChanged(); + /** Adapt the selection to match an other pile */ + void adaptSelectionTo(const Pile* other); - /** How many cards are changed? */ - int cardsChanged() const; -}; + /** Matches the selection to an other pile? */ + bool selectionMatchesTo(const Pile* other, bool matchSuit = false) const; + /** Is the heap changed? */ + bool changed() const; -/** --- class FinalHeap ---------------------------------------------------- **/ + /** Reset changed property */ + void resetChanged(); -class FinalHeap : public Heap -{ -private: - bool bonus; + /** How many cards are changed? */ + int cardsChanged() const; + }; + + + //--- class Spider::FinalHeap ------------------------------------------------ + + class FinalHeap : public Heap + { + private: + bool bonus; + + public: -public: + /** Constructor */ + FinalHeap(const Deck& deck); - /** Constructor */ - FinalHeap(const Deck& deck); + /** Set bonus of the final heap */ + void setBonus(bool newBonus); - /** Set bonus of the final heap */ - void setBonus(bool newBonus); + /** Has this final heap bonus? */ + bool getBonus() const; + }; - /** Has this final heap bonus? */ - bool getBonus() const; -}; +} // namespace Spider #endif // VDR_SPIDER_HEAP_H |