Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/lang/base_object.cc @ 9806

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

try with the shader

File size: 4.0 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 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: Patrick Boenzli
13   co-programmer: Benjamin Grauer
14*/
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_BASE
16
17#include "base_object.h"
18
19#include "debug.h"
20#include "util/loading/load_param.h"
21
22ObjectListDefinition(BaseObject);
23
24/**
25 * @brief sets the name from a LoadXML-Element
26 * @param objectName: The name of the Object.
27 */
28BaseObject::BaseObject(const std::string& objectName)
29{
30  this->className = "BaseObject";
31
32  this->objectName = objectName;
33  this->xmlElem = NULL;
34}
35
36/**
37 * @brief standard deconstructor
38*/
39BaseObject::~BaseObject ()
40{
41  /// Remove from the ObjectLists
42  ClassList::iterator it;
43  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
44  {
45    (*it)._objectList->unregisterObject((*it)._iterator);
46    delete (*it)._iterator;
47  }
48
49  if (this->xmlElem != NULL)
50    delete this->xmlElem;
51}
52
53/**
54 * @brief loads parameters
55 * @param root the element to load from
56 */
57void BaseObject::loadParams(const TiXmlElement* root)
58{
59  // all loadParams should arrive here, and be tested for (root != NULL)
60  assert (root != NULL);
61
62  // copy the xml-element for to know how it was loaded.
63  if (this->xmlElem != NULL)
64    delete this->xmlElem;
65  this->xmlElem = root->Clone();
66
67  // name setup
68  LoadParam(root, "name", this, BaseObject, setName)
69      .describe("the Name of the Object.");
70}
71
72/**
73 * @brief set the name of the Object
74 * @param objectName The new name of the Object.
75 */
76void BaseObject::setName (const std::string& objectName)
77{
78  this->objectName = objectName;
79}
80
81
82/**
83 * @brief Seeks in the Inheritance if it matches objectList.
84 * @param objectList The ObjectList this should be a member of (by Pointer-comparison).
85 * @return True if found, false if not.
86 */
87bool BaseObject::isA(const ObjectListBase& objectList) const
88{
89  ClassList::const_iterator it;
90  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
91    if ((*it)._objectList == &objectList)
92      return true;
93  return false;
94}
95
96
97/**
98 * @brief Seeks in the Inheritance if it matches objectList.
99 * @param classID The ClassID this should be a member of (by Pointer-comparison).
100 * @return True if found, false if not.
101 */
102bool BaseObject::isA(const ClassID& classID) const
103{
104  ClassList::const_iterator it;
105  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
106    if (*(*it)._objectList == classID)
107      return true;
108  return false;
109}
110
111/**
112 * @brief Seeks in the Inheritance if it matches objectList.
113 * @param classID The ClassID of the class this should be a member of.
114 * @return True if found, false if not.
115 */
116bool BaseObject::isA(int classID) const
117{
118  ClassList::const_iterator it;
119  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
120    if (*(*it)._objectList == classID)
121      return true;
122  return false;
123}
124
125/**
126 * @brief Seeks in the Inheritance if it matches objectList.
127 * @param className The ClassName of the class this should be a member of.
128 * @return True if found, false if not.
129 */
130bool BaseObject::isA(const std::string& className) const
131{
132  ClassList::const_iterator it;
133  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
134    if (*(*it)._objectList == className)
135      return true;
136  return false;
137}
138
139
140/**
141 * @brief This is for debug purposes, to see the Inheritances of this Object and its classes.
142 *
143 * The Inheritance will be listed in a Linear fashion, diamand structures are resolved in a linear dependency.
144 */
145void BaseObject::listInheritance() const
146{
147  PRINT(0)("Listing inheritance diagram for %s::%s: ", getClassCName(), getCName());
148  ClassList::const_iterator it;
149  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
150    PRINT(0)(" -> %s(id:%d)", (*it)._objectList->name().c_str(), (*it)._objectList->id());
151  PRINT(0)("\n");
152
153}
Note: See TracBrowser for help on using the repository browser.