X-Git-Url: http://git.maemo.org/git/?p=lordsawar;a=blobdiff_plain;f=src%2FUniquelyIdentified.cpp;fp=src%2FUniquelyIdentified.cpp;h=e9af8509df4c41a92200b78509a85c1cf3b49793;hp=0000000000000000000000000000000000000000;hb=9eda00ff73353c55ecef6f82131166d5d4a85e29;hpb=3d34d4aa85a929f912464f71158396a388274f27 diff --git a/src/UniquelyIdentified.cpp b/src/UniquelyIdentified.cpp new file mode 100644 index 0000000..e9af850 --- /dev/null +++ b/src/UniquelyIdentified.cpp @@ -0,0 +1,65 @@ +// Copyright (C) 2001, 2002, 2003 Michael Bartl +// Copyright (C) 2004, 2005 Ulf Lorenz +// Copyright (C) 2005 Andrea Paternesi +// Copyright (C) 2007, 2008 Ben Asselstine +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Library General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +// 02110-1301, USA. + +#include "config.h" +#include "UniquelyIdentified.h" +#include "counter.h" +#include "xmlhelper.h" + +UniquelyIdentified::UniquelyIdentified() +{ + d_id = fl_counter->getNextId(); + d_unique = true; +} + +UniquelyIdentified::UniquelyIdentified(const UniquelyIdentified& obj) + :d_id(obj.d_id), d_unique(false) +{ +} + +UniquelyIdentified::UniquelyIdentified(guint32 id) +{ + d_id = id; + d_unique = false; + syncNewId(); +} + +UniquelyIdentified::UniquelyIdentified(XML_Helper* helper) +{ + helper->getData(d_id, "id"); + //only unique objects are saved. + d_unique = true; +} + +UniquelyIdentified::~UniquelyIdentified() +{ +} + +void UniquelyIdentified::syncNewId() +{ + //we sync to the one after, so we don't reuse the same id + fl_counter->syncToId(d_id + 1); +} + +void UniquelyIdentified::assignNewId() +{ + d_id = fl_counter->getNextId(); + d_unique = true; +}