Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9696 in orxonox.OLD for branches/new_class_id


Ignore:
Timestamp:
Aug 24, 2006, 10:50:47 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: more functionality: getObject, getObjectList, and many new doxy-tags

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

Legend:

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

    r9685 r9696  
    113113
    114114/**
     115 * @brief Searches for a ObjectList with the ID classID
     116 * @param classID the ID to search for.
     117 * @return The NewObjectList if found, NULL otherwise.
     118 */
     119const NewObjectListBase* const NewObjectListBase::getObjectList(int classID)
     120{
     121  assert (NewObjectListBase::_classesByID != NULL);
     122  NewObjectListBase::classIDMap::iterator it = NewObjectListBase::_classesByID->find(classID);
     123  if (it != NewObjectListBase::_classesByID->end())
     124    return (*it).second;
     125  else
     126    return NULL;
     127}
     128
     129/**
     130 * @brief Searches for a ObjectList with the Name className
     131 * @param className the Name to search for.
     132 * @return The NewObjectList if found, NULL otherwise.
     133 */
     134const NewObjectListBase* const NewObjectListBase::getObjectList(const std::string& className)
     135{
     136  assert (NewObjectListBase::_classesByName != NULL);
     137  NewObjectListBase::classNameMap::iterator it = NewObjectListBase::_classesByName->find(className);
     138  if (it != NewObjectListBase::_classesByName->end())
     139    return (*it).second;
     140  else
     141    return NULL;
     142}
     143
     144/**
     145 * @brief Searches for a ObjectList with the NewClassID classID
     146 * @param classID the ID to search for.
     147 * @return The NewObjectList if found, NULL otherwise.
     148 */
     149const NewObjectListBase* const NewObjectListBase::getObjectList(const NewClassID& classID)
     150{
     151  return NewObjectListBase::getObjectList(classID.id());
     152}
     153
     154/**
     155 * @brief Retrieves the first BaseObject matching the name objectName from the List matching classID.
     156 * @param classID the ID of the List.
     157 * @param objectName the Name of the Object to search for
     158 */
     159BaseObject* NewObjectListBase::getObject(int classID, const std::string& objectName)
     160{
     161  const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID);
     162
     163  if (base != NULL)
     164    return base->getBaseObject(objectName);
     165  else
     166    return NULL;
     167}
     168
     169/**
     170 * @brief Retrieves the first BaseObject matching the name objectName from the List matching className.
     171 * @param className the Name of the List.
     172 * @param objectName the Name of the Object to search for
     173 */
     174BaseObject* NewObjectListBase::getObject(const std::string& className, const std::string& objectName)
     175{
     176  const NewObjectListBase* const base = NewObjectListBase::getObjectList(className);
     177
     178  if (base != NULL)
     179    return base->getBaseObject(objectName);
     180  else
     181    return NULL;
     182}
     183
     184/**
     185 * @brief Retrieves the first BaseObject matching the name objectName from the List matching classID.
     186 * @param classID The NewClassID of the List.
     187 * @param objectName the Name of the Object to search for
     188 */
     189BaseObject* NewObjectListBase::getObject(const NewClassID& classID, const std::string& objectName)
     190{
     191  const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID);
     192
     193  if (base != NULL)
     194    return base->getBaseObject(objectName);
     195  else
     196    return NULL;
     197}
     198
     199
     200/**
    115201 * @brief Converts an ID into a ClassName String.
    116202 * @param classID The ID to convert.
     
    119205const std::string& NewObjectListBase::IDToString(int classID)
    120206{
    121   assert (NewObjectListBase::_classesByID != NULL);
    122   NewObjectListBase::classIDMap::iterator it = NewObjectListBase::_classesByID->find(classID);
    123   if (it != NewObjectListBase::_classesByID->end())
    124     return (*it).second->name();
     207  const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID);
     208
     209  if (base != NULL)
     210    return base->name();
    125211  else
    126212  {
     
    138224int NewObjectListBase::StringToID(const std::string& className)
    139225{
    140   assert (NewObjectListBase::_classesByName != NULL);
    141   NewObjectListBase::classNameMap::iterator it = NewObjectListBase::_classesByName->find(className);
    142   if (it != NewObjectListBase::_classesByName->end())
    143     return (*it).second->id();
     226  const NewObjectListBase* const base = NewObjectListBase::getObjectList(className);
     227
     228  if (base != NULL)
     229    return base->id();
    144230  else
    145231    return -1;
  • branches/new_class_id/src/lib/lang/new_object_list.h

    r9695 r9696  
    116116  virtual base_iterator base_end() const = 0;
    117117
     118  static const NewObjectListBase* const getObjectList(int classID);
     119  static const NewObjectListBase* const getObjectList(const std::string& className);
     120  static const NewObjectListBase* const getObjectList(const NewClassID& classID);
     121
     122  static BaseObject* getObject(int classID, const std::string& objectName);
     123  static BaseObject* getObject(const std::string& className, const std::string& objectName);
     124  static BaseObject* getObject(const NewClassID& classID, const std::string& objectName);
     125
     126  virtual BaseObject* getBaseObject(const std::string& name) const = 0;
    118127
    119128protected:
     
    166175  ~NewObjectList();
    167176
     177  virtual BaseObject*     getBaseObject(const std::string& name) const;
    168178  T*                      getObject(const std::string& name) const;
    169179  inline const list&      objects() const { return _objects; };
     
    239249}
    240250
     251/**
     252 * @brief Retrieves a BaseObject matching the Name name in this List.
     253 * @param name the Name of the Object.
     254 * @returns a BaseObject pointing to the object if found, NULL otherwise.
     255 */
     256template <class T>
     257BaseObject* NewObjectList<T>::getBaseObject(const std::string& name) const
     258{
     259  return this->getObject(name);
     260}
     261
     262
     263
     264/**
     265 * @brief Retrieves an Object of type T matching the Name name in this List.
     266 * @param name the Name of the Object.
     267 * @returns an Object of type T pointing to the object if found, NULL otherwise.
     268 */
    241269template <class T>
    242270T* NewObjectList<T>::getObject(const std::string& name) const
     
    249277}
    250278
     279/**
     280 * @brief registers an Object to the NewObjectList.
     281 * @param T object the Object to register.
     282 * @returns a pointer to the iterator inside of the list.
     283 */
    251284template <class T>
    252285NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object)
     
    256289}
    257290
     291/**
     292 * @brief removes an Object from the ClassList.
     293 * @param iterator the Position at which to remove the Object.
     294 */
    258295template <class T>
    259296void NewObjectList<T>::unregisterObject(IteratorBase* iterator)
     
    263300}
    264301
    265 
     302/**
     303 * @brief print out some debug information
     304 * @note this function will most probably vanish from here and be completely moved to the base class.
     305 */
    266306template <class T>
    267307void NewObjectList<T>::debug() const
Note: See TracChangeset for help on using the changeset viewer.