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
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2006 orx
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.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
17
18#include "new_class_id.h"
19#include <cassert>
20
21ClassIDDeclaration::ClassIDDeclaration(const std::string& name)
22  : _id(-1), _name(name)
23{
24  NewClassID::registerClass(this);
25}
26
27ClassIDDeclaration::~ClassIDDeclaration()
28{
29  NewClassID::unregisterClass(this);
30}
31
32
33
34///////////////////////////////////////////////////////////
35//// CLASS ID definiton. //////////////////////////////////
36///////////////////////////////////////////////////////////
37/**
38 * @brief standard constructor
39 */
40NewClassID::NewClassID ()
41  : _className("")
42{
43}
44
45
46/**
47 * @brief standard deconstructor
48 */
49NewClassID::~NewClassID ()
50{
51  // delete what has to be deleted here
52}
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.