Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/lang/new_object_list.cc @ 9673

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

trunk: just realized, that polimorphism again is the evil part of classes.
Classes, that derive say from PNode and Element2D force that Element2D is registered after PNode, which means, that Element2D is interpretet as being derived from PNode in my implmentational idea…
hmm… now go for some new approach, this cannot and will not be the end of this…

File size: 1.4 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_object_list.h"
19#include <cassert>
20
21
22NewObjectListBase::NewObjectListBase(const std::string& className)
23    : _id(-1), _name(className)
24{
25  if (NewObjectListBase::_classes == NULL)
26    NewObjectListBase::_classes = new cSet;
27
28
29  assert(!NewObjectListBase::classNameExists(className) && "Classes should not be included once, and no two classes should have the same name (key value)");
30
31  this->_id = NewObjectListBase::_idCounter++;
32
33}
34
35NewObjectListBase::~NewObjectListBase()
36{
37
38}
39
40int NewObjectListBase::_idCounter = 0;
41NewObjectListBase::cSet* NewObjectListBase::_classes = NULL;
42
43
44
45/**
46 * @brief Checks if a Class with name already exists.
47 * @param name The Name of the Class to check.
48 * @return true if such a class already exists.
49 */
50bool NewObjectListBase::classNameExists(const std::string& name)
51{
52  cSet::iterator it;
53  for (it = NewObjectListBase::_classes->begin(); it != NewObjectListBase::_classes->end(); it++)
54    if(*it != NULL && (*it)->name() != name)
55      return true;
56  return false;
57}
Note: See TracBrowser for help on using the repository browser.