Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9661 in orxonox.OLD for trunk/src/lib/lang


Ignore:
Timestamp:
Aug 20, 2006, 12:21:18 PM (18 years ago)
Author:
bensch
Message:

renamings

Location:
trunk/src/lib/lang
Files:
2 edited

Legend:

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

    r9660 r9661  
    2020
    2121
    22 NewClassListBase::NewClassListBase(const std::string& className)
    23   : _id(-1), _name(className)
     22NewObjectListBase::NewObjectListBase(const std::string& className)
     23    : _id(-1), _name(className)
     24{
     25  if (NewObjectListBase::_classes == NULL)
     26    NewObjectListBase::_classes = new cList;
     27  assert(!NewObjectListBase::exists(className) && "Classes should not be included once, and no two classes should have the same name (key value)");
     28
     29
     30
     31}
     32
     33NewObjectListBase::~NewObjectListBase()
    2434{
    2535
    2636}
     37
     38int NewObjectListBase::_idCounter = 0;
     39NewObjectListBase::cList* NewObjectListBase::_classes = NULL;
     40
     41
     42
     43/**
     44 * @brief Checks if a Class with name already exists.
     45 * @param name The Name of the Class to check.
     46 * @return true if such a class already exists.
     47 */
     48bool NewObjectListBase::exists(const std::string& name)
     49{
     50  cList::iterator it;
     51  for (it = NewObjectListBase::_classes->begin(); it != NewObjectListBase::_classes->end(); it++)
     52    if(*it != NULL && (*it)->name() != name)
     53      return true;
     54  return false;
     55}
  • trunk/src/lib/lang/new_class_list.h

    r9660 r9661  
    1313
    1414#define DeclareClass(ClassName) \
    15    NewClassList ClassID_##ClassName(ClassName)
     15   NewObjectList ClassID_##ClassName(ClassName)
    1616
    1717#define DeclareInClass(ClassName) \
    18    NewClassList classList(ClassName)
     18   NewObjectList classList(ClassName)
    1919
    20 class NewClassListBase
     20class NewObjectListBase
    2121{
    2222public:
     
    2626  static int classCount() { return _idCounter; };
    2727
     28  bool compareName(const NewObjectListBase& more) { return this->_name < more.name(); };
     29  bool compareID(const NewObjectListBase& more) { return this->_id < more.id(); };
     30
    2831protected:
    29   NewClassListBase(const std::string& className);
     32  NewObjectListBase(const std::string& className);
     33  ~NewObjectListBase();
    3034private:
    31   NewClassListBase(const NewClassListBase&);
     35  NewObjectListBase(const NewObjectListBase&);
    3236
     37  static bool exists(const std::string& className);
    3338
    3439private:
     
    3742
    3843private:
     44  typedef std::set<NewObjectListBase*>  cList;
     45
    3946  static int                           _idCounter;      //!< A counter, that gives all classes a Unique ClassID. Access to this Variable is to be Thread-Safe.
    40   static std::set<NewClassListBase>    _classes;        //!< A Set of all the classes in existance.
     47  static cList*                        _classes;        //!< A Set of all the classes in existance.
    4148};
    4249
    43 template<class T> class NewClassList : public NewClassListBase
     50
     51/////////////////////////
     52//// TEMPLATISATION /////
     53/////////////////////////
     54template<class T> class NewObjectList : public NewObjectListBase
    4455{
    4556public:
    46   NewClassList(const std::string& name);
    47   ~NewClassList();
     57  NewObjectList(const std::string& name);
     58  ~NewObjectList();
    4859
    4960private:
    5061  //! the copy constructor will be hidden.
    51   NewClassList(const NewClassList& definer) {};
     62  NewObjectList(const NewObjectList& definer) {};
    5263};
    5364
    5465template <class T>
    55 NewClassList<T>::NewClassList(const std::string& name)
    56     : NewClassListBase(name)
     66NewObjectList<T>::NewObjectList(const std::string& name)
     67    : NewObjectListBase(name)
    5768{}
    5869
    5970template <class T>
    60 NewClassList<T>::~NewClassList()
     71NewObjectList<T>::~NewObjectList()
    6172{}
    6273
Note: See TracChangeset for help on using the changeset viewer.