All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PhysicsFactory.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Nate Koenig
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 /*
18  * Desc: Factory for creating physics engine
19  * Author: Nate Koenig
20  * Date: 21 May 2009
21  */
22 
23 #ifndef _PHYSICSFACTORY_HH_
24 #define _PHYSICSFACTORY_HH_
25 
26 #include <string>
27 #include <map>
28 
29 #include "physics/PhysicsTypes.hh"
30 
31 namespace gazebo
32 {
33  namespace physics
34  {
37 
41 
45  {
47  public: static void RegisterAll();
48 
53  public: static void RegisterPhysicsEngine(std::string _className,
54  PhysicsFactoryFn _factoryfn);
55 
59  public: static PhysicsEnginePtr NewPhysicsEngine(
60  const std::string &_className, WorldPtr _world);
61 
63  private: static std::map<std::string, PhysicsFactoryFn> engines;
64  };
65 
71  #define GZ_REGISTER_PHYSICS_ENGINE(name, classname) \
72  PhysicsEnginePtr New##classname(WorldPtr _world) \
73  { \
74  return PhysicsEnginePtr(new gazebo::physics::classname(_world)); \
75  } \
76  void Register##classname() \
77  {\
78  PhysicsFactory::RegisterPhysicsEngine(name, New##classname);\
79  }
80 
81  }
82 }
83 #endif