Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9726 in orxonox.OLD for branches/new_class_id/src


Ignore:
Timestamp:
Sep 9, 2006, 7:42:16 PM (18 years ago)
Author:
bensch
Message:

stuff from yesterday

Location:
branches/new_class_id/src/lib/lang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/lang/object_list.cc

    r9725 r9726  
    1919#include <cassert>
    2020
    21 
    22 #include <stdio.h>
    23 
    2421/**
    2522 * @brief Constructor, that creates an ObjectList while checking (development mode) for uniqueness of all Keys (names and ID's)
     
    3330  if (ObjectListBase::_classesByID == NULL)
    3431  {
    35     ObjectListBase::_classesByID = new classIDMap;
     32    ObjectListBase::_classesByID = new IDMap;
    3633    assert (ObjectListBase::_classesByName == NULL);
    37     ObjectListBase::_classesByName = new classNameMap;
     34    ObjectListBase::_classesByName = new NameMap;
    3835  }
    3936  assert(!ObjectListBase::classNameExists(className) && "Classes should only be included once, and no two classes should have the same name (key value)");
     
    8380}
    8481
    85 ObjectListBase::classIDMap* ObjectListBase::_classesByID = NULL;
    86 ObjectListBase::classNameMap* ObjectListBase::_classesByName = NULL;
     82ObjectListBase::IDMap* ObjectListBase::_classesByID = NULL;
     83ObjectListBase::NameMap* ObjectListBase::_classesByName = NULL;
    8784std::list<std::string> ObjectListBase::_classNames;
    8885
     
    156153{
    157154  assert (ObjectListBase::_classesByID != NULL);
    158   ObjectListBase::classIDMap::iterator it = ObjectListBase::_classesByID->find(classID);
     155  ObjectListBase::IDMap::iterator it = ObjectListBase::_classesByID->find(classID);
    159156  if (it != ObjectListBase::_classesByID->end())
    160157    return (*it).second;
     
    171168{
    172169  assert (ObjectListBase::_classesByName != NULL);
    173   ObjectListBase::classNameMap::iterator it = ObjectListBase::_classesByName->find(className);
     170  ObjectListBase::NameMap::iterator it = ObjectListBase::_classesByName->find(className);
    174171  if (it != ObjectListBase::_classesByName->end())
    175172    return (*it).second;
     
    243240    ObjectListBase::_classNames.clear();
    244241
    245     for (classNameMap::const_iterator it = ObjectListBase::_classesByName->begin();
    246          it != ObjectListBase::_classesByName->end();
    247          ++it)
    248     {
     242    for (NameMap::const_iterator it = ObjectListBase::_classesByName->begin();
     243         it != ObjectListBase::_classesByName->end();
     244         ++it)
    249245      ObjectListBase::_classNames.push_back((*it).second->name());
    250     }
    251246  }
    252247  return ObjectListBase::_classNames;
     
    294289  printf("Listing all %d ObjectLists \n", ObjectListBase::_classesByID->size());
    295290
    296   for (classNameMap::const_iterator it = ObjectListBase::_classesByName->begin();
     291  for (NameMap::const_iterator it = ObjectListBase::_classesByName->begin();
    297292       it != ObjectListBase::_classesByName->end();
    298293       ++it)
    299   {
    300294    (*it).second->debug(level);
    301 
    302   }
    303 
    304295}
    305296
     
    339330    return -1;
    340331}
    341 
  • branches/new_class_id/src/lib/lang/object_list.h

    r9724 r9726  
    99
    1010#include "class_id.h"
    11 #include <cassert>
    1211#include <map>
    1312#include <list>
    1413#include <string>
     14
     15#include <cassert>
    1516#include <iostream>
    1617
     
    101102  static int                            StringToID(const std::string& className);
    102103
    103   //! Only uset to unsubscribe a BaseObject.
     104  //! Only used to unsubscribe a BaseObject. (just try to make a valid iterator, stupid :))
    104105  virtual void                          unregisterObject(IteratorBase* _iterators) = 0;
    105106
     
    117118
    118119protected:
    119   typedef std::map<int, ObjectListBase*>         classIDMap;   //!< The Generic Map.
    120   typedef std::map<std::string, ObjectListBase*> classNameMap; //!< The Generic Map.
     120  typedef std::map<int, ObjectListBase*>         IDMap;   //!< The Generic Map.
     121  typedef std::map<std::string, ObjectListBase*> NameMap; //!< The Generic Map.
    121122
    122123private:
     
    126127
    127128private:
    128   static classIDMap*            _classesByID;       //!< A Map of all the classes in existance.
    129   static classNameMap*          _classesByName;     //!< A Map of all the classes in existance.
     129  static IDMap*                 _classesByID;       //!< A Map of all the classes in existance.
     130  static NameMap*               _classesByName;     //!< A Map of all the classes in existance.
    130131  static std::list<std::string> _classNames;        //!< A list of all the registered ClassNames.
    131132};
     
    135136//// TEMPLATISATION /////
    136137/////////////////////////
    137 //! Defines a ObjectsList handler for objects of type T.
     138//! Defines a ObjectList handler for objects of type T.
    138139/**
    139140 * The ObjectList is a generic way to store every object created from a Class 'T'
    140  *  into a List. The list can be retrieved, and used constantly over iterators,
     141 *  in a List. The list can be retrieved, and used constantly over iterators,
    141142 *  as with normal std::list.
    142143 *
    143144 * Furthermore the linkage over the single Lists is given over the Superclass ObjectListBase.
    144145 *
    145  *
    146  *
     146 * The approach of ObjectList is an intrusive one, meaning, that each Class that wants to
     147 * support it must implement a Declaration and a Definition for the ObjectList, as mentioned
     148 * in the next statement:
    147149 *
    148150 * To define a Class with a ObjectList, you have to:
     
    152154 *
    153155 * @note The Class must define the compare with const std::string& operator for this to work.
     156 *  The operator==(const std::string& name) should compare the object's name with name.
    154157 *
    155158 *
Note: See TracChangeset for help on using the changeset viewer.