Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2006, 10:51:08 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/new_class_id: new_class ID working, adapdet many classes, and reinvented some of the ClassID stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/loading/factory.cc

    r9695 r9709  
    2828 * set everything to zero and define factoryName
    2929 */
    30 Factory::Factory (const std::string& factoryName, int classID)
    31     : _classID(classID), _className(factoryName)
     30Factory::Factory (const NewClassID& classID)
     31    : _classID(classID)
    3232{
    33   this->registerObject(this, Factory::_objectList);
    34   this->setName(factoryName);
     33  printf("Factory::create(%s::%d)\n", classID.name().c_str(), classID.id());
     34  //this->registerObject(this, Factory::_objectList);
     35  this->setName(classID.name());
    3536
    3637  if( Factory::_factoryList == NULL)
     
    7980}
    8081
    81 /**
    82  * @brief Compares the Factories Name against a given ClassName
    83  * @param className the Name of the Class to Query
    84  * @returns true on match, false otherwise.
    85  */
    86 bool Factory::operator==(const char* className) const
    87 {
    88   return (className != NULL && this->_className == className);
    89 }
    9082
    9183/**
     
    9688bool Factory::operator==(const std::string& className) const
    9789{
    98   return (this->_className == className);
     90  return (this->_classID.name() == className);
    9991}
    10092
     
    143135}
    144136
    145 
    146137/**
    147138 * @brief Creates a new Object of type classID
     
    149140 * @returns a new Object of Type classID on match, NULL otherwise
    150141 */
    151 BaseObject* Factory::fabricate(int classID)
     142BaseObject* Factory::fabricate(const NewClassID& classID)
    152143{
    153144  if (Factory::_factoryList == NULL)
     
    157148  for (factory = Factory::_factoryList->begin(); factory != Factory::_factoryList->end(); factory++)
    158149    if (*(*factory) == classID)
    159     {
    160       PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
    161       return (*factory)->fabricateObject(NULL);
     150  {
     151    PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
     152    return (*factory)->fabricateObject(NULL);
    162153
    163     }
    164   PRINTF(2)("Could not Fabricate an Object of ClassID '0x%h'\n", classID);
     154  }
     155  PRINTF(2)("Could not Fabricate an Object of ClassID '%d'\n", classID.id());
    165156  return NULL;
    166157}
    167 
    168 
    169 /**
    170  * @brief Creates a new Object of type classID
    171  * @param classID the ClassID to match for the newly created Object
    172  * @returns a new Object of Type classID on match, NULL otherwise
    173  */
    174 BaseObject* Factory::fabricate(const NewClassID& classID)
    175 {
    176   return Factory::fabricate(classID.id());
    177 }
Note: See TracChangeset for help on using the changeset viewer.