initial commit, lordsawar source, slightly modified
[lordsawar] / src / counter.cpp
1 // Copyright (C) 2003 Michael Bartl
2 // Copyright (C) 2003, 2005 Ulf Lorenz
3 // Copyright (C) 2007, 2008 Ben Asselstine
4 // Copyright (C) 2008 Ole Laursen
5 //
6 //  This program is free software; you can redistribute it and/or modify
7 //  it under the terms of the GNU General Public License as published by
8 //  the Free Software Foundation; either version 3 of the License, or
9 //  (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU Library General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
19 //  02110-1301, USA.
20
21 #include "counter.h"
22
23 #include "xmlhelper.h"
24
25 std::string FL_Counter::d_tag = "counter";
26
27 FL_Counter* fl_counter;
28
29 FL_Counter::FL_Counter(guint32 start)
30     :d_curID(start)
31 {
32 }
33
34 FL_Counter::FL_Counter(XML_Helper* helper)
35 {
36     helper->getData(d_curID, "curID");
37 }
38
39 FL_Counter::~FL_Counter()
40 {
41 }
42
43 void FL_Counter::syncToId(guint32 id)
44 {
45   if (id > d_curID)
46     d_curID = id;
47 }
48
49 guint32 FL_Counter::getNextId()
50 {
51   guint32 ret = d_curID;
52   d_curID++;
53   return ret;
54 }
55
56 bool FL_Counter::save(XML_Helper* helper)
57 {
58     bool retval =true;
59
60     retval &= helper->openTag(FL_Counter::d_tag);
61     retval &= helper->saveData("curID", d_curID);
62     retval &= helper->closeTag();
63
64     return retval;
65 }
66