Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6280 in orxonox.OLD for trunk/src/lib/lang/base_object.cc


Ignore:
Timestamp:
Dec 25, 2005, 2:46:33 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: ClassList now supports getLeafID() to retriefe the ID on hot to generate an object of the same type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/base_object.cc

    r6278 r6280  
    2727
    2828/**
    29  * sets the name from a LoadXML-Element
     29 * @brief sets the name from a LoadXML-Element
    3030 * @param root the element to load from
    3131 */
     
    3636
    3737  this->objectName = NULL;
     38  this->classList = NULL;
    3839
    3940  if (root)
     
    4445
    4546/**
    46  * standard deconstructor
     47 * @brief standard deconstructor
    4748*/
    4849BaseObject::~BaseObject ()
     
    5657
    5758/**
    58  * loads parameters
     59 * @brief loads parameters
    5960 * @param root the element to load from
    6061 */
     
    6768
    6869/**
    69  * sets the class identifiers
     70 * @brief sets the class identifiers
    7071 * @param id a number for the class from class_id.h enumeration
    7172 * @param className the class name
     
    7980  this->className = className;
    8081
    81   ClassList::addToClassList(this, classID, this->classID, className);
     82  this->classList = ClassList::addToClassList(this, classID, this->classID, className);
    8283}
    8384
     85
    8486/**
    85  * @briefbrief set the name of the Object
     87 * @brief set the name of the Object
    8688 */
    8789void BaseObject::setName (const char* objectName)
     
    98100}
    99101
     102/**
     103 * @brief queries for the ClassID of the Leaf Class (the last made class of this type
     104 * @returns the ClassID of the Leaf Class (e.g. the ID of the Class)
     105 *
     106 * the returned ID can be used to generate new Objects of the same type through
     107 * Factory::fabricate(Object->getLeafClassID());
     108 */
     109ClassID BaseObject::getLeafClassID() const
     110{
     111  assert (this->classList != NULL);
     112  return this->classList->getLeafClassID();
     113}
     114
     115
    100116
    101117/**
    102  * checks if the class is a classID
     118 * @brief checks if the class is a classID
    103119 * @param classID the Identifier to check for
    104120 * @returns true if it is, false otherwise
     
    128144}
    129145
     146
     147
    130148/**
    131  * checks if the class is a classID
     149 * @brief checks if the class is a classID
    132150 * @param classID the Identifier to check for
    133151 * @returns true if it is, false otherwise
     
    140158}
    141159
     160
    142161/**
    143  * compares the ObjectName with an external name
     162 * @brief compares the ObjectName with an external name
    144163 * @param objectName: the name to check.
    145164 * @returns true on match, false otherwise.
     
    153172
    154173/**
    155  * displays everything this class is
     174 * @brief displays everything this class is
    156175 * @TODO REIMPLEMENT WITH SENSE.
    157176 */
    158177void BaseObject::whatIs() const
    159178{
    160   PRINT(0)("object %s of class %s: ", this->getName(), this->getClassName());
    161   if ((this->classID & CL_MASK_SINGLETON) == CL_MASK_SINGLETON)
    162     PRINT(0)("is a Singleton-Class ");
    163   if (this->classID & CL_MASK_SUPER_CLASS)
    164   {
    165     PRINT(0)(" ->is a derived from the following superclasses:");
    166     if (this->isA(CL_BASE_OBJECT))
    167       PRINT(0)(" =BaseObject=");
    168     if (this->isA(CL_PARENT_NODE))
    169       PRINT(0)(" =PNode=");
    170     if (this->isA(CL_WORLD_ENTITY))
    171       PRINT(0)(" =WorldEntity=");
    172     if (this->isA(CL_PHYSICS_INTERFACE))
    173       PRINT(0)(" =PhysicsInterface=");
    174     if (this->isA(CL_EVENT_LISTENER))
    175       PRINT(0)(" =EventListener=");
    176     if (this->isA(CL_STORY_ENTITY))
    177       PRINT(0)(" =StoryEntity=");
    178     if (this->isA(CL_ELEMENT_2D))
    179       PRINT(0)(" =Element2D=");
    180     PRINT(0)("\n");
    181   }
    182   // subsuper-classes
    183   if (this->classID & CL_MASK_SUBSUPER_CLASS)
    184   {
    185     PRINT(0)(" ->further derivations: ");
    186     if (this->isA(CL_PLAYER))
    187       PRINT(0)(" -Player-");
    188     if (this->isA(CL_NPC))
    189       PRINT(0)(" -NPC-");
    190     if (this->isA(CL_POWER_UP))
    191       PRINT(0)(" -PowerUp-");
    192     if (this->isA(CL_FIELD))
    193       PRINT(0)(" -Field-");
    194     if (this->isA(CL_PROJECTILE))
    195       PRINT(0)(" -Projectile-");
    196     if (this->isA(CL_WEAPON))
    197       PRINT(0)(" -Weapon-");
    198     PRINT(0)("\n");
     179
    199180}
    200 }
Note: See TracChangeset for help on using the changeset viewer.