ManaPlus
equipment.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef EQUIPMENT_H
25 #define EQUIPMENT_H
26 
27 #include "localconsts.h"
28 
29 class Item;
30 
32 {
33  public:
39  { }
40 
42 
43 
47  { mBackend = nullptr; }
48 
50  {
51  public:
53  { }
54 
56 
57  virtual const Item *getEquipment(const int index)
58  const A_WARN_UNUSED = 0;
59 
60  virtual void clear() = 0;
61 
62  virtual ~Backend()
63  { }
64  };
65 
69  const Item *getEquipment(const int index) const A_WARN_UNUSED
70  {
71  return mBackend != nullptr ?
72  mBackend->getEquipment(index) : nullptr;
73  }
74 
78  void clear()
79  { if (mBackend != nullptr) mBackend->clear(); }
80 
84  void setEquipment(int index,
85  int id,
86  int quantity);
87 
88  void setBackend(Backend *const backend)
89  { mBackend = backend; }
90 
92  { return mBackend; }
93 
94  private:
96 };
97 
98 #endif // EQUIPMENT_H
virtual const Item * getEquipment(const int index) const =0
virtual void clear()=0
Equipment()
Definition: equipment.h:37
~Equipment()
Definition: equipment.h:46
void setEquipment(int index, int id, int quantity)
void clear()
Definition: equipment.h:78
const Backend * getBackend() const
Definition: equipment.h:91
void setBackend(Backend *const backend)
Definition: equipment.h:88
const Item * getEquipment(const int index) const
Definition: equipment.h:69
Backend * mBackend
Definition: equipment.h:95
Definition: item.h:50
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
#define nullptr
Definition: localconsts.h:45