Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/lang/base_object.cc @ 9370

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

trunk: merged the gui back
merged with command:
svn merge -r8114:HEAD https://svn.orxonox.net/orxonox/branches/gui .
→ no conflicts

File size: 4.1 KB
RevLine 
[3302]1
2
[4591]3/*
[3302]4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
[6640]15   co-programmer: Benjamin Grauer
[3302]16*/
[5439]17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_BASE
[3302]18
19#include "base_object.h"
[4747]20
[7193]21#include "util/loading/load_param.h"
[4747]22#include "class_list.h"
[3302]23
[6341]24#include "synchronizeable.h"
25
[3302]26using namespace std;
27
28
29/**
[6280]30 * @brief sets the name from a LoadXML-Element
[4836]31 * @param root the element to load from
[5439]32 */
[7661]33BaseObject::BaseObject(const std::string& objectName)
[3531]34{
[7221]35  this->classID = CL_BASE_OBJECT;
[6276]36  this->className = "BaseObject";
[4435]37
[7661]38  this->objectName = objectName;
[6280]39  this->classList = NULL;
[6517]40  this->xmlElem = NULL;
[4436]41
[7429]42  //ClassList::addToClassList(this, this->classID, "BaseObject");
[3531]43}
[3302]44
45/**
[6280]46 * @brief standard deconstructor
[3302]47*/
[4591]48BaseObject::~BaseObject ()
[3531]49{
[4747]50  ClassList::removeFromClassList(this);
51
[4261]52  //  delete []this->className;
[6517]53  if (this->xmlElem != NULL)
54    delete this->xmlElem;
[5447]55}
[3302]56
[4436]57/**
[6280]58 * @brief loads parameters
[4836]59 * @param root the element to load from
[5439]60 */
[4436]61void BaseObject::loadParams(const TiXmlElement* root)
62{
[6517]63  // all loadParams should sometime arrive here.
64  assert (root != NULL);
65
66  if (this->xmlElem != NULL)
67    delete this->xmlElem;
68  this->xmlElem = root->Clone();
[4436]69  // name setup
[5671]70  LoadParam(root, "name", this, BaseObject, setName)
[5645]71      .describe("the Name of the Object.");
[4436]72}
[4321]73
74/**
[6280]75 * @brief sets the class identifiers
[4836]76 * @param id a number for the class from class_id.h enumeration
77 * @param className the class name
[4321]78*/
[7221]79void BaseObject::setClassID(ClassID classID, const std::string& className)
[4320]80{
[6282]81  //printf("%s(0x%.8X)->%s(0x%.8X)\n", this->className, this->classID, className, classID);
82  assert (!(this->classID & classID & !CL_MASK_SUBSUPER_CLASS_IDA ));
[6276]83
[7954]84  this->leafClassID = classID;
[5791]85  this->classID |= (long)classID;
[4320]86  this->className = className;
[4747]87
[6280]88  this->classList = ClassList::addToClassList(this, classID, this->classID, className);
[4320]89}
[4318]90
[6280]91
[4435]92/**
[6280]93 * @brief set the name of the Object
[4591]94 */
[7221]95void BaseObject::setName (const std::string& objectName)
[4435]96{
[7221]97  this->objectName = objectName;
[4435]98}
[4592]99
[6281]100
[6280]101/**
102 * @brief queries for the ClassID of the Leaf Class (the last made class of this type
103 * @returns the ClassID of the Leaf Class (e.g. the ID of the Class)
104 *
105 * the returned ID can be used to generate new Objects of the same type through
106 * Factory::fabricate(Object->getLeafClassID());
107 */
[7954]108const ClassID& BaseObject::getLeafClassID() const
[6280]109{
[7954]110  return this->leafClassID;
[6280]111}
[4592]112
[6280]113
114
[4592]115/**
[6280]116 * @brief checks if the class is a classID
[4836]117 * @param classID the Identifier to check for
118 * @returns true if it is, false otherwise
[4592]119*/
[6077]120bool BaseObject::isA (ClassID classID) const
[4592]121{
[4837]122  // if classID is a derivable object from a SUPERCLASS
123  if (classID & CL_MASK_SUPER_CLASS)
[4594]124  {
[4837]125    if( likely(this->classID & classID))
[4594]126      return true;
[4837]127  }
128  // if classID is a SubSuperClass, and
129  else if (classID & CL_MASK_SUBSUPER_CLASS)
130  {
[7123]131    if (likely(((this->classID & CL_MASK_SUBSUPER_CLASS_IDA) == (classID & CL_MASK_SUBSUPER_CLASS_IDA)) &&
[5915]132        this->classID & classID & CL_MASK_SUBSUPER_CLASS_IDB))
[4837]133      return true;
134  }
135  // if classID is a LOWLEVEL-class
[4594]136  else
137  {
[4837]138    if( likely((this->classID & CL_MASK_LOWLEVEL_CLASS) == classID))
[4594]139      return true;
140  }
[4592]141  return false;
142}
143
[6280]144
145
[4592]146/**
[6280]147 * @brief checks if the class is a classID
[5513]148 * @param classID the Identifier to check for
149 * @returns true if it is, false otherwise
150 */
[7221]151bool BaseObject::isA (const std::string& className) const
[5513]152{
[6077]153  ClassID classID = ClassList::StringToID(className);
[5513]154  if (classID != CL_NULL)
155    return this->isA(classID);
[8145]156  else
157    return false;
[5513]158}
159
[6280]160
[5626]161/**
[6280]162 * @brief compares the ObjectName with an external name
[5626]163 * @param objectName: the name to check.
164 * @returns true on match, false otherwise.
165 */
[7221]166bool BaseObject::operator==(const std::string& objectName)
[5626]167{
[7221]168  return (this->objectName == objectName);
[5626]169}
[5513]170
[5626]171
[5513]172/**
[6280]173 * @brief displays everything this class is
[5642]174 * @TODO REIMPLEMENT WITH SENSE.
[4592]175 */
[4746]176void BaseObject::whatIs() const
[4592]177{
[6280]178
[4592]179}
Note: See TracBrowser for help on using the repository browser.