Warning, file /education/step/stepcore/factory.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "factory.h" 0008 #include "world.h" 0009 #include "solver.h" 0010 #include "collisionsolver.h" 0011 #include "constraintsolver.h" 0012 0013 namespace StepCore { 0014 0015 // XXX: locking 0016 void Factory::registerMetaObject(const MetaObject* metaObject) 0017 { 0018 _metaObjects.insert(metaObject->className(), metaObject); 0019 } 0020 0021 const MetaObject* Factory::metaObject(const QString& name) const 0022 { 0023 return _metaObjects.value(name, NULL); 0024 } 0025 0026 Object* Factory::newObject(const QString& name) const 0027 { 0028 const MetaObject* metaObject = this->metaObject(name); 0029 if(!metaObject) return nullptr; 0030 return metaObject->newObject(); 0031 } 0032 0033 Item* Factory::newItem(const QString& name) const 0034 { 0035 const MetaObject* metaObject = this->metaObject(name); 0036 if(!metaObject || !metaObject->inherits<Item>()) return nullptr; 0037 return static_cast<Item*>(metaObject->newObject()); 0038 } 0039 0040 Solver* Factory::newSolver(const QString& name) const 0041 { 0042 const MetaObject* metaObject = this->metaObject(name); 0043 if(!metaObject || !metaObject->inherits<Solver>()) return nullptr; 0044 return static_cast<Solver*>(metaObject->newObject()); 0045 } 0046 0047 CollisionSolver* Factory::newCollisionSolver(const QString& name) const 0048 { 0049 const MetaObject* metaObject = this->metaObject(name); 0050 if(!metaObject || !metaObject->inherits<CollisionSolver>()) return nullptr; 0051 return static_cast<CollisionSolver*>(metaObject->newObject()); 0052 } 0053 0054 ConstraintSolver* Factory::newConstraintSolver(const QString& name) const 0055 { 0056 const MetaObject* metaObject = this->metaObject(name); 0057 if(!metaObject || !metaObject->inherits<ConstraintSolver>()) return nullptr; 0058 return static_cast<ConstraintSolver*>(metaObject->newObject()); 0059 } 0060 0061 } // namespace StepCore 0062