De-constify piece types.
[tagua/yd.git] / src / core / pool.h
bloba521aebd3ed23a38fdb46bffa3b441e0a1ac2beb
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, 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;
58 virtual Piece get(int index) = 0;
60 /**
61 * Delete a piece from the pool.
62 * @param index The index of the piece to delete.
63 * @returns The piece removed from the pool by this call.
65 virtual Piece take(int index) = 0;
67 /**
68 * Delete a piece from the pool.
69 * @param piece The piece to delete.
70 * @returns Whether the specified piece has successfully been deleted.
72 virtual bool take(Piece& piece) = 0;
75 #endif // CORE__POOL_H