• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

step/stepcore

  • sources
  • kde-4.12
  • kdeedu
  • step
  • stepcore
factory.cc
Go to the documentation of this file.
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 #include "factory.h"
20 #include "world.h"
21 #include "solver.h"
22 #include "collisionsolver.h"
23 #include "constraintsolver.h"
24 
25 namespace StepCore {
26 
27 // XXX: locking
28 void Factory::registerMetaObject(const MetaObject* metaObject)
29 {
30  _metaObjects.insert(metaObject->className(), metaObject);
31 }
32 
33 const MetaObject* Factory::metaObject(const QString& name) const
34 {
35  return _metaObjects.value(name, NULL);
36 }
37 
38 Object* Factory::newObject(const QString& name) const
39 {
40  const MetaObject* metaObject = this->metaObject(name);
41  if(!metaObject) return NULL;
42  return metaObject->newObject();
43 }
44 
45 Item* Factory::newItem(const QString& name) const
46 {
47  const MetaObject* metaObject = this->metaObject(name);
48  if(!metaObject || !metaObject->inherits<Item>()) return NULL;
49  return static_cast<Item*>(metaObject->newObject());
50 }
51 
52 Solver* Factory::newSolver(const QString& name) const
53 {
54  const MetaObject* metaObject = this->metaObject(name);
55  if(!metaObject || !metaObject->inherits<Solver>()) return NULL;
56  return static_cast<Solver*>(metaObject->newObject());
57 }
58 
59 CollisionSolver* Factory::newCollisionSolver(const QString& name) const
60 {
61  const MetaObject* metaObject = this->metaObject(name);
62  if(!metaObject || !metaObject->inherits<CollisionSolver>()) return NULL;
63  return static_cast<CollisionSolver*>(metaObject->newObject());
64 }
65 
66 ConstraintSolver* Factory::newConstraintSolver(const QString& name) const
67 {
68  const MetaObject* metaObject = this->metaObject(name);
69  if(!metaObject || !metaObject->inherits<ConstraintSolver>()) return NULL;
70  return static_cast<ConstraintSolver*>(metaObject->newObject());
71 }
72 
73 } // namespace StepCore
74 
StepCore::MetaObject::className
const QString & className() const
Returns class name.
Definition: object.h:185
StepCore::MetaObject::newObject
Object * newObject() const
Creates new object of this class.
Definition: object.h:200
StepCore::Factory::newObject
Object * newObject(const QString &name) const
Create new Object by class name.
Definition: factory.cc:38
StepCore::Object
Root of the StepCore classes hierarchy.
Definition: object.h:57
StepCore::Solver
Generic Solver interface.
Definition: solver.h:70
collisionsolver.h
CollisionSolver interface.
world.h
Item, Body, Force and Tool interfaces, World class.
StepCore::Factory::newConstraintSolver
ConstraintSolver * newConstraintSolver(const QString &name) const
Create new ConstraintSolver by class name.
Definition: factory.cc:66
constraintsolver.h
ConstraintSolver interface.
StepCore::Item
The root class for any world items (bodies and forces)
Definition: world.h:69
factory.h
Factory classes.
StepCore::Factory::registerMetaObject
void registerMetaObject(const MetaObject *metaObject)
Register MetaObject.
Definition: factory.cc:28
StepCore::CollisionSolver
Collision solver interface.
Definition: collisionsolver.h:85
StepCore::Factory::newItem
Item * newItem(const QString &name) const
Create new Item by class name.
Definition: factory.cc:45
solver.h
Solver interface.
StepCore::Factory::metaObject
const MetaObject * metaObject(const QString &name) const
Find MetaObject by name.
Definition: factory.cc:33
StepCore::Factory::_metaObjects
QHash< QString, const MetaObject * > _metaObjects
Definition: factory.h:64
StepCore::MetaObject
Meta-information about class.
Definition: object.h:176
StepCore::MetaObject::inherits
bool inherits(const MetaObject *obj) const
Returns true if this class inherits class described by obj.
Definition: object.cc:73
StepCore::Factory::newCollisionSolver
CollisionSolver * newCollisionSolver(const QString &name) const
Create new CollisionSolver by class name.
Definition: factory.cc:59
StepCore::ConstraintSolver
Constraint solver interface.
Definition: constraintsolver.h:40
StepCore::Factory::newSolver
Solver * newSolver(const QString &name) const
Create new Solver by class name.
Definition: factory.cc:52
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:43:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal