/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: ... */ #include "base_object.h" #include "load_param.h" using namespace std; /** \brief sets the name from a LoadXML-Element \param root the element to load from */ BaseObject::BaseObject(const TiXmlElement* root) { this->className = NULL; this->id = -1; this->finalized = false; this->objectName = NULL; if (root) this->loadParams(root); } /** \brief standard deconstructor */ BaseObject::~BaseObject () { // delete []this->className; if (this->objectName) delete []this->objectName; } /** \brief loads parameters \param root the element to load from */ void BaseObject::loadParams(const TiXmlElement* root) { // name setup LoadParam(root, "name", this, &BaseObject::setName) .describe("the name of the Object at hand"); } /** \brief sets the class identifiers \param a number for the class from class_list.h enumeration \param the class name */ void BaseObject::setClassID(int id, const char* className) { this->id = id; this->className = className; } /** \brief sets the class identifier \param a number for the class from class_list.h enumeration */ void BaseObject::setClassID (int id) { this->id = id; } /** \brief sets the class identifiers \param the class name */ void BaseObject::setClassName(const char* className) { this->className = className; } /** \brief sets the class identifiers \param a number for the class from class_list.h enumeration \param the class name */ bool BaseObject::isA (char* className) { if( this->className == className) return false; return true; } /* \brief this finalizes an object and makes it ready to be garbage collected */ void BaseObject::finalize() { this->finalized = true; } /** \brief set the name of the node for debug purposes realy usefull, not used to work properly */ void BaseObject::setName (const char* newName) { if (this->objectName) delete []this->objectName; if (newName) { this->objectName = new char[strlen(newName)+1]; strcpy(this->objectName, newName); } else this->objectName = NULL; }