Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/lang/new_class_id.cc @ 9659

Last change on this file since 9659 was 9659, checked in by bensch, 18 years ago

some thoughts

File size: 1.5 KB
RevLine 
[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]21ClassIDDeclaration::ClassIDDeclaration(const std::string& name)
22  : _id(-1), _name(name)
23{
24  NewClassID::registerClass(this);
25}
[1853]26
[9659]27ClassIDDeclaration::~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 */
40NewClassID::NewClassID ()
41  : _className("")
[3365]42{
43}
[1853]44
45
[3245]46/**
[9659]47 * @brief standard deconstructor
48 */
49NewClassID::~NewClassID ()
[3543]50{
51  // delete what has to be deleted here
52}
[9659]53
54
55int NewClassID::_idCounter = 0;
56
57//! TODO make access to the idCounter ThreadSafe!
58void 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
65void NewClassID::unregisterClass(ClassIDDeclaration* namer)
66{
67  // here nothing is done, because Classes cannot be realigned fast.
68}
Note: See TracBrowser for help on using the repository browser.