File indexing completed on 2024-03-03 03:59:17

0001 /*
0002     SPDX-FileCopyrightText: 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 /** \file factory.h
0008  *  \brief Factory classes
0009  */
0010 
0011 #ifndef STEPCORE_FACTORY_H
0012 #define STEPCORE_FACTORY_H
0013 
0014 #include "object.h"
0015 
0016 #include <QHash>
0017 
0018 namespace StepCore {
0019 
0020 class Item;
0021 class Solver;
0022 class CollisionSolver;
0023 class ConstraintSolver;
0024 
0025 /** \ingroup reflections
0026  *  \brief List of MetaObject
0027  */
0028 class Factory
0029 {
0030 public:
0031     /** Register MetaObject */
0032     void registerMetaObject(const MetaObject* metaObject);
0033 
0034     /** Find MetaObject by name */
0035     const MetaObject* metaObject(const QString& name) const;
0036 
0037     /** Get QHash of all registered MetaObject */
0038     const QHash<QString, const MetaObject*>& metaObjects() const { return _metaObjects; }
0039 
0040     /** Create new Object by class name */
0041     Object* newObject(const QString& name) const;
0042     /** Create new Item by class name */
0043     Item* newItem(const QString& name) const;
0044     /** Create new Solver by class name */
0045     Solver* newSolver(const QString& name) const;
0046     /** Create new CollisionSolver by class name */
0047     CollisionSolver* newCollisionSolver(const QString& name) const;
0048     /** Create new ConstraintSolver by class name */
0049     ConstraintSolver* newConstraintSolver(const QString& name) const;
0050 
0051 protected:
0052     QHash<QString, const MetaObject*> _metaObjects;
0053 };
0054 
0055 } // namespace StepCore
0056 
0057 #endif // STEPCORE_FACTORY_H
0058