Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5156 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Aug 27, 2005, 3:57:42 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: no more segfaults wenn creating entities

Location:
trunk/src/util/loading
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/loading/factory.cc

    r5155 r5156  
    9595    {
    9696      PRINTF(3)("Create a new Object of type %s\n", fac->getName());
    97       BaseObject* object = fac->fabricate(NULL);
     97      BaseObject* object = fac->fabricateDirect();
    9898      if (object != NULL)
    9999      {
  • trunk/src/util/loading/factory.h

    r5155 r5156  
    4141 public:
    4242  Factory (const char* factoryName = NULL);
    43   ~Factory ();
     43  virtual ~Factory ();
    4444
    4545  void fabricate(const char* className, const char* entityName);
    4646  virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
     47  virtual BaseObject* fabricateDirect() = NULL;
    4748
    4849  static void registerFactory( Factory* factory);
     
    7374  private:
    7475  virtual BaseObject* fabricate(const TiXmlElement* root);
     76  virtual BaseObject* fabricateDirect();
    7577};
    7678
     
    9395BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
    9496{
     97  if (root == NULL)
     98    return NULL;
     99
    95100  if(!strcmp(root->Value(), this->getName()))
    96101    return new T ( root);
     
    101106}
    102107
     108template<class T>
     109    BaseObject* tFactory<T>::fabricateDirect()
     110{
     111  return new T((const TiXmlElement*)NULL);
     112}
     113
    103114#endif /* _FACTORY_H */
    104115
Note: See TracChangeset for help on using the changeset viewer.