Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4438 was 4436, checked in by bensch, 20 years ago

orxonox/trunk: baseObject now implements loading of objectNames

File size: 2.5 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->id = -1;
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 a number for the class from class_list.h enumeration
65   \param the class name
66*/
67void BaseObject::setClassID(int id, const char* className)
68{
69  this->id = id;
70  this->className = className;
71}
72
73
74/**
75   \brief sets the class identifier
76   \param a number for the class from class_list.h enumeration
77*/
78void BaseObject::setClassID (int id)
79{
80  this->id = id;
81}
82
83
84/**
85   \brief sets the class identifiers
86   \param the class name
87*/
88void BaseObject::setClassName(const char* className)
89{
90  this->className = className;
91}
92
93
94/**
95   \brief sets the class identifiers
96   \param a number for the class from class_list.h enumeration
97   \param the class name
98*/
99bool BaseObject::isA (char* className)
100{
101  if( this->className == className)
102    return false;
103  return true;
104}
105
106
107/*
108  \brief this finalizes an object and makes it ready to be garbage collected
109*/
110void BaseObject::finalize()
111{
112  this->finalized = true;
113}
114
115
116/**
117  \brief set the name of the node
118
119  for debug purposes realy usefull, not used to work properly
120*/
121void BaseObject::setName (const char* newName)
122{
123  if (this->objectName)
124    delete []this->objectName;
125  if (newName)
126    {
127      this->objectName = new char[strlen(newName)+1];
128      strcpy(this->objectName, newName);
129    }
130  else 
131    this->objectName = NULL;
132}
Note: See TracBrowser for help on using the repository browser.