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 2012 Open Source Robotics Foundation
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 
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 
65  public: static bool IsRegistered(const std::string &_name);
66 
68  private: static std::map<std::string, PhysicsFactoryFn> engines;
69  };
70 
76  #define GZ_REGISTER_PHYSICS_ENGINE(name, classname) \
77  PhysicsEnginePtr New##classname(WorldPtr _world) \
78  { \
79  return PhysicsEnginePtr(new gazebo::physics::classname(_world)); \
80  } \
81  void Register##classname() \
82  {\
83  PhysicsFactory::RegisterPhysicsEngine(name, New##classname);\
84  }
85 
86  }
87 }
88 #endif