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
RevLine 
[4591]1/*
[3302]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
[6640]13   co-programmer: Benjamin Grauer
[3302]14*/
[5439]15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_BASE
[3302]16
17#include "base_object.h"
[4747]18
[9727]19#include "debug.h"
[7193]20#include "util/loading/load_param.h"
[3302]21
[9715]22ObjectListDefinition(BaseObject);
[9691]23
[3302]24/**
[6280]25 * @brief sets the name from a LoadXML-Element
[9724]26 * @param objectName: The name of the Object.
[5439]27 */
[7661]28BaseObject::BaseObject(const std::string& objectName)
[3531]29{
[6276]30  this->className = "BaseObject";
[4435]31
[7661]32  this->objectName = objectName;
[6517]33  this->xmlElem = NULL;
[3531]34}
[3302]35
36/**
[6280]37 * @brief standard deconstructor
[3302]38*/
[4591]39BaseObject::~BaseObject ()
[3531]40{
[9715]41  /// Remove from the ObjectLists
[9684]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  }
[4747]48
[6517]49  if (this->xmlElem != NULL)
50    delete this->xmlElem;
[5447]51}
[3302]52
[4436]53/**
[6280]54 * @brief loads parameters
[4836]55 * @param root the element to load from
[5439]56 */
[4436]57void BaseObject::loadParams(const TiXmlElement* root)
58{
[9406]59  // all loadParams should arrive here, and be tested for (root != NULL)
[6517]60  assert (root != NULL);
61
[9406]62  // copy the xml-element for to know how it was loaded.
[6517]63  if (this->xmlElem != NULL)
64    delete this->xmlElem;
65  this->xmlElem = root->Clone();
[9406]66
[4436]67  // name setup
[5671]68  LoadParam(root, "name", this, BaseObject, setName)
[5645]69      .describe("the Name of the Object.");
[4436]70}
[4321]71
72/**
[6280]73 * @brief set the name of the Object
[9406]74 * @param objectName The new name of the Object.
[4591]75 */
[7221]76void BaseObject::setName (const std::string& objectName)
[4435]77{
[7221]78  this->objectName = objectName;
[4435]79}
[4592]80
[6281]81
[6280]82/**
[9684]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.
[6280]86 */
[9715]87bool BaseObject::isA(const ObjectListBase& objectList) const
[6280]88{
[9684]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;
[6280]94}
[4592]95
[9686]96
[4592]97/**
[9684]98 * @brief Seeks in the Inheritance if it matches objectList.
[9724]99 * @param classID The ClassID this should be a member of (by Pointer-comparison).
[9686]100 * @return True if found, false if not.
101 */
[9715]102bool BaseObject::isA(const ClassID& classID) const
[9686]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.
[9684]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
[4592]117{
[9684]118  ClassList::const_iterator it;
119  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
120    if (*(*it)._objectList == classID)
[4594]121      return true;
[4592]122  return false;
123}
124
125/**
[9684]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.
[5513]129 */
[9684]130bool BaseObject::isA(const std::string& className) const
[5513]131{
[9684]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;
[5513]137}
138
[6280]139
[9724]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 */
[9684]145void BaseObject::listInheritance() const
[5626]146{
[9806]147  PRINT(0)("Listing inheritance diagram for %s::%s: ", getClassCName(), getCName());
[9684]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
[5626]153}
Note: See TracBrowser for help on using the repository browser.