1 /* This file is part of StepCore library.
2    Copyright (C) 2007 Vladimir Kuznetsov <ks.vladimir@gmail.com>
3 
4    StepCore library is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8 
9    StepCore library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with StepCore; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18 
19 /** \file factory.h
20  *  \brief Factory classes
21  */
22 
23 #ifndef STEPCORE_FACTORY_H
24 #define STEPCORE_FACTORY_H
25 
26 #include "object.h"
27 
28 #include <QHash>
29 
30 namespace StepCore {
31 
32 class Item;
33 class Solver;
34 class CollisionSolver;
35 class ConstraintSolver;
36 
37 /** \ingroup reflections
38  *  \brief List of MetaObject
39  */
40 class Factory
41 {
42 public:
43     /** Register MetaObject */
44     void registerMetaObject(const MetaObject* metaObject);
45 
46     /** Find MetaObject by name */
47     const MetaObject* metaObject(const QString& name) const;
48 
49     /** Get QHash of all registered MetaObject */
metaObjects()50     const QHash<QString, const MetaObject*>& metaObjects() const { return _metaObjects; }
51 
52     /** Create new Object by class name */
53     Object* newObject(const QString& name) const;
54     /** Create new Item by class name */
55     Item* newItem(const QString& name) const;
56     /** Create new Solver by class name */
57     Solver* newSolver(const QString& name) const;
58     /** Create new CollisionSolver by class name */
59     CollisionSolver* newCollisionSolver(const QString& name) const;
60     /** Create new ConstraintSolver by class name */
61     ConstraintSolver* newConstraintSolver(const QString& name) const;
62 
63 protected:
64     QHash<QString, const MetaObject*> _metaObjects;
65 };
66 
67 } // namespace StepCore
68 
69 #endif // STEPCORE_FACTORY_H
70 
71