Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: restructure class_list.h so it supports inheritance-diagram

File size: 2.3 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/*
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 set the name of the Object
109 */
110void BaseObject::setName (const char* objectName)
111{
112  if (this->objectName)
113    delete []this->objectName;
114  if (objectName)
115    {
116      this->objectName = new char[strlen(objectName)+1];
117      strcpy(this->objectName, objectName);
118    }
119  else
120    this->objectName = NULL;
121}
Note: See TracBrowser for help on using the repository browser.