Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

cleanup

File size: 2.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#include "debug.h"
21
22///////////////////////////////////////////////////////////
23//// CLASS ID definiton. //////////////////////////////////
24///////////////////////////////////////////////////////////
25/**
26 * @brief standard constructor
27 */
28NewClassID::NewClassID ()
29{}
30
31
32/**
33 * @brief standard deconstructor
34 */
35NewClassID::~NewClassID ()
36{
37  ClassList::iterator it;
38  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
39  {
40    (*it)._objectList->unregisterObject((*it)._iterator);
41    delete (*it)._iterator;
42  }
43}
44
45
46/**
47 * @brief Seeks in the Inheritance if it matches objectList.
48 * @param objectList The ObjectList this should be a member of (by Pointer-comparison).
49 * @return True if found, false if not.
50 */
51bool NewClassID::isA(const NewObjectListBase& objectList) const
52{
53  ClassList::const_iterator it;
54  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
55    if ((*it)._objectList == &objectList)
56      return true;
57  return false;
58}
59
60/**
61 * @brief Seeks in the Inheritance if it matches objectList.
62 * @param classID The ClassID of the class this should be a member of.
63 * @return True if found, false if not.
64 */
65bool NewClassID::isA(int classID) const
66{
67  ClassList::const_iterator it;
68  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
69    if (*(*it)._objectList == classID)
70      return true;
71  return false;
72}
73
74/**
75 * @brief Seeks in the Inheritance if it matches objectList.
76 * @param className The ClassName of the class this should be a member of.
77 * @return True if found, false if not.
78 */
79bool NewClassID::isA(const std::string& className) const
80{
81  ClassList::const_iterator it;
82  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
83    if (*(*it)._objectList == className)
84      return true;
85  return false;
86}
87
88
89void NewClassID::listInheritance() const
90{
91  PRINT(0)("Listing inheritance diagram for ....: ");
92  ClassList::const_iterator it;
93  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
94    PRINT(0)(" -> %s(id:%d)", (*it)._objectList->name().c_str(), (*it)._objectList->id());
95  PRINT(0)("\n");
96
97}
Note: See TracBrowser for help on using the repository browser.