Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4592 was 4592, checked in by bensch, 19 years ago

orxonox/trunk: derivations work.
now the only thing to do is specify all the classes, and DO it CLEAN.

@patrick: is it ok, how i treated your ObjectManager??

File size: 3.0 KB
Line 
1
2
3/*
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
15   co-programmer: ...
16*/
17
18
19#include "base_object.h"
20#include "load_param.h"
21
22using namespace std;
23
24
25/**
26   \brief sets the name from a LoadXML-Element
27   \param root the element to load from
28*/
29BaseObject::BaseObject(const TiXmlElement* root)
30{
31  this->className = NULL;
32  this->classID = CL_BASE_OBJECT;
33  this->finalized = false;
34
35  this->objectName = NULL;
36
37  if (root)
38    this->loadParams(root);
39}
40
41/**
42   \brief standard deconstructor
43*/
44BaseObject::~BaseObject ()
45{
46  //  delete []this->className;
47  if (this->objectName)
48    delete []this->objectName;
49}
50
51/**
52   \brief loads parameters
53   \param root the element to load from
54*/
55void BaseObject::loadParams(const TiXmlElement* root)
56{
57  // name setup
58  LoadParam<BaseObject>(root, "name", this, &BaseObject::setName)
59  .describe("the name of the Object at hand");
60}
61
62/**
63   \brief sets the class identifiers
64   \param id a number for the class from class_list.h enumeration
65   \param className the class name
66*/
67void BaseObject::setClassID(long classID, const char* className)
68{
69  this->setClassID(classID);
70  this->setClassName(className);
71}
72
73
74/**
75   \brief sets the class identifier
76   \param id a number for the class from class_list.h enumeration
77*/
78void BaseObject::setClassID (long classID)
79{
80  this->classID |= classID;
81}
82
83
84/**
85   \brief sets the class identifiers
86   \param className the class name
87*/
88void BaseObject::setClassName(const char* className)
89{
90  this->className = className;
91}
92
93/**
94  \brief set the name of the Object
95 */
96             void BaseObject::setName (const char* objectName)
97{
98  if (this->objectName)
99    delete []this->objectName;
100  if (objectName)
101  {
102    this->objectName = new char[strlen(objectName)+1];
103    strcpy(this->objectName, objectName);
104  }
105  else
106    this->objectName = NULL;
107}
108
109
110/**
111   \brief checks if the class is a classID
112   \param classID the Identifier to check for
113   \returns true if it is, false otherwise
114*/
115bool BaseObject::isA (ClassID classID)
116{
117  if( this->classID & classID)
118    return true;
119  return false;
120}
121
122/**
123 * @brief displays everything this class is
124 */
125void BaseObject::whatIs(void) const
126{
127  PRINT(0)("object %s: ", this->getName() );
128  if (this->classID & CL_MASK_SUPERCLASS)
129  {
130    PRINT(0)("is a derived Class from: \n");
131    if (this->classID & CL_BASE_OBJECT)
132      PRINT(0)("BaseObject, ");
133    if (this->classID & CL_PARENT_NODE)
134      PRINT(0)("ParentNode, ");
135    if (this->classID & CL_WORLD_ENTITY)
136      PRINT(0)("WorldEntity, ");
137    if (this->classID & CL_PHYSICS_INTERFACE)
138      PRINT(0)("PhysicsInterface, ");
139    if (this->classID & CL_EVENT_LISTENER)
140      PRINT(0)("EventListener, ");
141    if (this->classID & CL_STORY_ENTITY)
142      PRINT(0)("StoryEntity, ");
143  }
144  printf("\n");
145}
Note: See TracBrowser for help on using the repository browser.