1 // Copyright (C) 2008, Ben Asselstine
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.
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.
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
20 #include "armyprodbase.h"
21 #include "xmlhelper.h"
23 std::string ProdSlot::d_tag = "slot";
25 //#define debug(x) {std::cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<std::endl<<std::flush;}
30 d_armyprodbase = NULL;
33 ProdSlot::ProdSlot(const ProdSlot& object)
35 if (object.d_armyprodbase != NULL)
36 d_armyprodbase = new ArmyProdBase(*object.d_armyprodbase);
38 d_armyprodbase = NULL;
41 ProdSlot::ProdSlot(XML_Helper* helper)
43 d_armyprodbase = NULL;
44 helper->registerTag(ArmyProdBase::d_tag,
45 sigc::mem_fun(this, &ProdSlot::load));
49 bool ProdSlot::load(std::string tag, XML_Helper *helper)
51 if (tag == ArmyProdBase::d_tag)
53 d_armyprodbase = new ArmyProdBase(helper);
63 delete d_armyprodbase;
64 d_armyprodbase = NULL;
68 bool ProdSlot::save(XML_Helper *helper) const
71 retval &= helper->openTag(ProdSlot::d_tag);
73 retval &= d_armyprodbase->save(helper);
74 retval &= helper->closeTag();
78 void ProdSlot::clear()
81 delete d_armyprodbase;
82 d_armyprodbase = NULL;