/*! Returns a new copy of the prototype specified by prototype_id. The id must be valid. Functions should use the id returned by registerPrototype. */ BaseNode *NodeFactory::produce(int prototype_id) { assert(prototype_id >= 0); assert(prototype_id < static_cast<int>(prototypes.size())); BaseNode* clone = prototypes.at(prototype_id)->clone(); // qDebug(qPrintable(id.toString())); clone->setId(QUuid::createUuid()); return clone; }
/*! Returns a new copy of the prototype specified by name, or null if the name isn't valid. */ BaseNode *NodeFactory::produceFromClassName(QString name) { std::vector<BaseNode*>::iterator it; BaseNode* clone; for (it=prototypes.begin(); it < prototypes.end(); it++) { if ((*it)->metaObject()->className() == name) { clone = (*it)->clone(); clone->setId(QUuid::createUuid()); return clone; } } qDebug("Error: couldn't produce class"); return 0; }