[4744] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
[9659] | 4 | Copyright (C) 2006 orx |
---|
[1853] | 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 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
[9659] | 12 | main-programmer: Benjamin Grauer |
---|
[1855] | 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
[1853] | 17 | |
---|
[9659] | 18 | #include "new_class_id.h" |
---|
| 19 | #include <cassert> |
---|
[1853] | 20 | |
---|
[9659] | 21 | ClassIDDeclaration::ClassIDDeclaration(const std::string& name) |
---|
| 22 | : _id(-1), _name(name) |
---|
| 23 | { |
---|
| 24 | NewClassID::registerClass(this); |
---|
| 25 | } |
---|
[1853] | 26 | |
---|
[9659] | 27 | ClassIDDeclaration::~ClassIDDeclaration() |
---|
| 28 | { |
---|
| 29 | NewClassID::unregisterClass(this); |
---|
| 30 | } |
---|
[1856] | 31 | |
---|
[9406] | 32 | |
---|
[9659] | 33 | |
---|
| 34 | /////////////////////////////////////////////////////////// |
---|
| 35 | //// CLASS ID definiton. ////////////////////////////////// |
---|
| 36 | /////////////////////////////////////////////////////////// |
---|
[3245] | 37 | /** |
---|
[9659] | 38 | * @brief standard constructor |
---|
| 39 | */ |
---|
| 40 | NewClassID::NewClassID () |
---|
| 41 | : _className("") |
---|
[3365] | 42 | { |
---|
| 43 | } |
---|
[1853] | 44 | |
---|
| 45 | |
---|
[3245] | 46 | /** |
---|
[9659] | 47 | * @brief standard deconstructor |
---|
| 48 | */ |
---|
| 49 | NewClassID::~NewClassID () |
---|
[3543] | 50 | { |
---|
| 51 | // delete what has to be deleted here |
---|
| 52 | } |
---|
[9659] | 53 | |
---|
| 54 | |
---|
| 55 | int NewClassID::_idCounter = 0; |
---|
| 56 | |
---|
| 57 | //! TODO make access to the idCounter ThreadSafe! |
---|
| 58 | void NewClassID::registerClass(ClassIDDeclaration* namer) |
---|
| 59 | { |
---|
| 60 | assert (namer->id() != -1 && "Do not register any ClassID's for yourself."); |
---|
| 61 | |
---|
| 62 | namer->_id = NewClassID::_idCounter++; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | void NewClassID::unregisterClass(ClassIDDeclaration* namer) |
---|
| 66 | { |
---|
| 67 | // here nothing is done, because Classes cannot be realigned fast. |
---|
| 68 | } |
---|