initial commit, lordsawar source, slightly modified
[lordsawar] / src / prodslot.h
1 //  Copyright (C) 2008, 2009 Ben Asselstine
2 //
3 //  This program is free software; you can redistribute it and/or modify
4 //  it under the terms of the GNU General Public License as published by
5 //  the Free Software Foundation; either version 3 of the License, or
6 //  (at your option) any later version.
7 //
8 //  This program is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 //  GNU Library General Public License for more details.
12 //
13 //  You should have received a copy of the GNU General Public License
14 //  along with this program; if not, write to the Free Software
15 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
16 //  02110-1301, USA.
17
18 #ifndef PRODSLOT_H
19 #define PRODSLOT_H
20
21 #include "vector.h"
22 #include <string>
23
24 class XML_Helper;
25 class ArmyProdBase;
26
27 //! A placeholder for an army production object.
28 /** 
29  * Slots can either be empty or point to an army production object.
30  */
31
32 class ProdSlot
33 {
34  public:
35      //! The xml tag of this object in a saved-game file.
36      static std::string d_tag;
37
38      //! Default constructor.
39      ProdSlot();
40
41      //! Copy constructor.
42      ProdSlot(const ProdSlot&);
43
44      //! Loading constructor.
45      ProdSlot(XML_Helper* helper);
46
47      //! Destructor.
48     ~ProdSlot();
49
50     // Set Methods
51  
52     //! Assign the armyprodbase associated with this object.
53     void setArmyProdBase(ArmyProdBase *prod) {d_armyprodbase = prod;};
54
55
56     // Get Methods
57
58     //! Return the armyprodbase associated with this object.
59     ArmyProdBase *getArmyProdBase() const {return d_armyprodbase;};
60
61
62     // Methods that operate on the class data but do not modify the class.
63
64     //! Save the production slot to an opened saved-game file.
65     bool save(XML_Helper *helper) const;
66
67
68     // Methods that operate ont he class data and modify the class.
69  
70     //! Delete and remove the armyprodbase from this object.
71     void clear();
72
73  private:
74
75     //! Callback to help in loading the armyprodbase into this object.
76     bool load(std::string tag, XML_Helper *helper);
77
78     //DATA
79
80     //! The armyprodbase object that this slot contains.
81     ArmyProdBase *d_armyprodbase;
82 };
83
84 #endif