1 // Copyright (C) 2001, 2002, 2003 Michael Bartl
2 // Copyright (C) 2004, 2005 Ulf Lorenz
3 // Copyright (C) 2004, 2006 Andrea Paternesi
4 // Copyright (C) 2007, 2008, 2009, 2014, 2015 Ben Asselstine
5 // Copyright (C) 2007 Ole Laursen
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License as published by
9 //  the Free Software Foundation; either version 3 of the License, or
10 //  (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU Library General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 //  02110-1301, USA.
21 
22 #pragma once
23 #ifndef UNIQUELYIDENTIFIED_H
24 #define UNIQUELYIDENTIFIED_H
25 
26 #include <gtkmm.h>
27 
28 class XML_Helper;
29 
30 //! A game object that has a unique numeric identifier.
31 class UniquelyIdentified
32 {
33  public:
34     //! Default constructor.
35     UniquelyIdentified();
36 
37     //! Copy constructor.
38     UniquelyIdentified(const UniquelyIdentified&);
39 
40     //! non-default constructor.
41     UniquelyIdentified(guint32 id);
42 
43     //! Loading constructor.
44     UniquelyIdentified(XML_Helper* helper);
45 
46     //! Destructor.
~UniquelyIdentified()47     virtual ~UniquelyIdentified() {};
48 
49 
50     // Get Methods
51 
52     //! Returns the unique numeric identifer of this object.
getId()53     guint32 getId() const {return d_id;}
54 
55 
56     //Methods that operate on class data and modify the class.
57 
58     //! Make the counter aware of this object by syncing it to one after this.
59     void syncNewId();
60 
61     //! Go get a new unique identifier for this object.
62     void assignNewId();
63 
isUnique()64     bool isUnique() {return d_unique;}
65  protected:
66 
67     //! A unique numeric identifier for an object in the game.
68     guint32 d_id;
69 
70     //! Whether or not this id is actually unique.
71     bool d_unique;
72 };
73 
74 #endif
75 
76 // End of file
77