refresh dc9ccb8c0bf4bc198802d4d39ad2bc523eb5e06f
[tagua/yd.git] / src / core / pool.h
blobc58809ca3754f432611e7f6273ecfbcde7310e3e
1 /*
2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef CORE__POOL_H
12 #define CORE__POOL_H
14 class Piece;
16 /**
17 * @brief A collection of pieces.
19 * A pool is a collection of pieces, typically displayed on the side
20 * of the board. Some games define special rules for moving pieces
21 * into and out from the pools.
23 class IPool {
24 public:
25 virtual ~IPool();
27 virtual IPool* clone() const = 0;
29 /**
30 * @return Whether two pools are equal, i.e. contain the same pieces.
32 virtual bool equals(const IPool* other) const = 0;
34 /**
35 * @return Whether this pool is empty.
37 virtual bool empty() const = 0;
39 /**
40 * @return The number of pieces in this pool.
42 virtual int size() const = 0;
44 /**
45 * Insert a new piece into the pool.
46 * Note that @a index is just a hint where the piece is to be
47 * added, and pool implementations may decide to put the piece
48 * at a different index.
49 * @returns The actual index where the newly inserted piece can be found.
51 virtual int insert(int index, const Piece& piece) = 0;
53 /**
54 * Retrieve a piece from the pool.
55 * @param index The index of the piece to retrieve.
57 virtual Piece get(int index) const = 0;
59 /**
60 * Delete a piece from the pool.
61 * @param index The index of the piece to delete.
62 * @returns The piece removed from the pool by this call.
64 virtual Piece take(int index) = 0;
66 /**
67 * Delete a piece from the pool.
68 * @param piece The piece to delete.
69 * @returns Whether the specified piece has successfully been deleted.
71 virtual bool take(const Piece& piece) = 0;
74 #endif // CORE__POOL_H